Forum Discussion

Robert Ohare's avatar
Robert Ohare
Copper Contributor
May 16, 2019

How would I add an image link to a page with the page title as the image name Classic Sharepoint

Hello All, 

 

I wanted to add an image that is dynamic to a DocSetHomepage. I want the Image that is displayed in the webpart to display to have the following format 

 

/teams/Base/Admin/Photos/(pagetitle).png 

 

I am not sure if I am just burnt out, but what would you do? how would you achieve this? The Webparts are not working like I want them. Even after using a page Field filter or CQWP. So the next thing would be to make the image static and pull from the photo library. 

  • Robert Ohare 

     

    You could add a Content Editor Web Part (CEWP) to the doc set home page.

     

    In that web part, grab add a root element, then have a <script> where you grab _spPageContextInfo to get your title, then build your <img src='/teams/Base/Admin/Photos/' + title + '.png'> from there and inject it into your root element.

Resources