none
Image display in sharepoint column RRS feed

  • Question

  • Hi,

    I am uploading files of different types in custom list.I am using on premise sharepoint server 2016.After uploading file,based on file type,icon should be displayed in list.

    I am using calculated column approach.But after applying formula,I am getting error.

    Formula:=IF([File Type]="WORD", "<DIV><img src='http://************/sites/DMS/_layouts/15/Lightbox.aspx?url=http://************/sites/DMS/Image Library/forSaleNew.png/'><DIV>", "")

    I have also tried to set image using picture column.I used jquery for it.But then too I am not able to display an image.
    What is the actual approach?Please ellaborate in steps if possible.


    Friday, July 19, 2019 1:17 PM

Answers

  • Hi,

    try it in this way,

    =IF([column A]="1","<img src='http://xxxxx.xxxxxx.local/krishna/SiteAssets/red_flag.jpeg'>","<img src='http://xxxxx.xxxxxx.local/krishna/SiteAssets/flag_3_right_blue_2_256.png'>")


    mistake in your approach is you are pointing to layouts folder the image should be in your library.

    Note: Ensure that you say the calculated column as number as part of column properties ( you should say number as part of Additional Column settings, after you provide the formula)

    Let me know if you need any further help, happy to help !!

    Enjoy the SharePoint !!

    Best Regards,
    Krishna

    Please remember to mark the replies as answers if they helped.

    Friday, July 19, 2019 3:56 PM
  • Hi AnonymousMicrosoftUser,

    You could create the calculated column and insert the formula as below.

    I suggest you should select “Number” data type for the calculated column, then it will display the image in the calculated column.

    =IF([File Type]="WORD","<img src='http://yoursite/SiteAssets/1.png'>","<img src='http://yoursite /SiteAssets/2.png'>")

    The result as below:


    Best regards,

    Sara Fan


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Tuesday, July 23, 2019 7:17 AM
    Moderator
  • Thank you for replies.I followed your approaches.I found that image can also be inserted by adding javascript code.My problem has been resolved.
    Tuesday, July 23, 2019 10:15 AM

All replies

  • Hi,

    try it in this way,

    =IF([column A]="1","<img src='http://xxxxx.xxxxxx.local/krishna/SiteAssets/red_flag.jpeg'>","<img src='http://xxxxx.xxxxxx.local/krishna/SiteAssets/flag_3_right_blue_2_256.png'>")


    mistake in your approach is you are pointing to layouts folder the image should be in your library.

    Note: Ensure that you say the calculated column as number as part of column properties ( you should say number as part of Additional Column settings, after you provide the formula)

    Let me know if you need any further help, happy to help !!

    Enjoy the SharePoint !!

    Best Regards,
    Krishna

    Please remember to mark the replies as answers if they helped.

    Friday, July 19, 2019 3:56 PM
  • Icon. You meant the file type default column?

    If this is helpful please mark it so. Also if this solved your problem mark as answer.

    Sunday, July 21, 2019 7:50 PM
    Moderator
  • Hi AnonymousMicrosoftUser,

    Do you mean the file type column? The file type column only exists in the document library.

    And in the list, we only can attach the file as the attachment in the item. And after you attach the file in the item, it will only display the item in the list, the file will not be display in the list.

    Where did you want to add the file type column in the list?

    And if you want to add the file type in the document library, then you could modify the view and select the “Type (icon linked to document)” column in the columns in the view.


    Best regards,

    Sara Fan


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Monday, July 22, 2019 7:49 AM
    Moderator
  • Hi,

    Has this problem been solved?

    If you think the replies are helpful to you, please remember to mark them as answers. It will help others who meet the similar question in this forum.

    Enjoy the SharePoint !!

    Best Regards,
    Krishna
    Please remember to mark the replies as answers if they helped.

    Monday, July 22, 2019 12:12 PM
  • Hi,

    @Sara Fan No.I didn't mean file type column.It is calculated column.I have tried with picture column too.


    Monday, July 22, 2019 12:31 PM
  • Hi,

    try it in this way,

    =IF([column A]="1","<img src='http://xxxxx.xxxxxx.local/krishna/SiteAssets/red_flag.jpeg'>","<img src='http://xxxxx.xxxxxx.local/krishna/SiteAssets/flag_3_right_blue_2_256.png'>")


    mistake in your approach is you are pointing to layouts folder the image should be in your library.

    Note: Ensure that you say the calculated column as number as part of column properties ( you should say number as part of Additional Column settings, after you provide the formula)

    Let me know if you need any further help, happy to help !!

    Enjoy the SharePoint !!

    Best Regards,
    Krishna

    Please remember to mark the replies as answers if they helped.

    Hi,

    Krishna Vandanapu Thank you.I followed your approach.Still I am getting error as 'One or more column references are not allowed,because the columns are defined as a data type that is not supported in formulas.' Is it due to  I am applying condition on a column of choice data type?



    Monday, July 22, 2019 12:58 PM
  • Hi AnonymousMicrosoftUser,

    You could create the calculated column and insert the formula as below.

    I suggest you should select “Number” data type for the calculated column, then it will display the image in the calculated column.

    =IF([File Type]="WORD","<img src='http://yoursite/SiteAssets/1.png'>","<img src='http://yoursite /SiteAssets/2.png'>")

    The result as below:


    Best regards,

    Sara Fan


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Tuesday, July 23, 2019 7:17 AM
    Moderator
  • Thank you for replies.I followed your approaches.I found that image can also be inserted by adding javascript code.My problem has been resolved.
    Tuesday, July 23, 2019 10:15 AM
  • Hi AnonymousMicrosoftUser,

    It is very happy that you have resolved your problem.

    Thank you for your sharing and it will help others have the same issue.

    If the reply is helpful to you, you could mark the reply as answer. Thanks for your understanding.

    Best regards,

    Sara Fan

    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Wednesday, July 24, 2019 1:32 AM
    Moderator