+ Start a Discussion

Issue With Displaying Images Using ContentDocumentLink

I am having trouble displaying images using Content Document Link in my aura component.
I had used these links for reference:

<aura:attribute name="Art" type="Article__c[]"/> 
<aura:iteration items="{!v.Art}" var="val">
 <li class="slds-size--3-of-3 slds-small-size_4-of-12 slds-show--inline-block"> <lightning:card variant="narrow" class="slds-m-around--small slds-card_boundary detailStyle bg-image">
 <ui:outputRichText class="pname" value="{!val.Name}" />
 <lightning:button class="slds-button slds-button_base mg-bt " aura:id="view1" variant="brand" name="{!val}" label="View" onclick="{!c.handleClick}" />

I had used this SOQL :
select id, ContentDocumentId, LinkedEntityId from ContentDocumentLink where LinkedEntityId = ''
 select id, ContentDocumentId from ContentVersion where ContentDocumentId = ''

Hi Lex08,

You can display an image using contentversion Id in the aura component. Take help from below piece of code:
<img src="{!('/sfc/servlet.shepherd/version/download/'+v.contentVersionId)}" style="width:auto; height:40vh;"/>

You can iterate a list or store the contentversion id in any attribute and use it as per your requirement.

Please mark it as best answer, if you find it helpful.

Sachin Arora