+ Start a Discussion
Lex08Lex08 

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:
https://www.mhamzas.com/blog/2020/01/09/use-salesforce-files-image-file-on-lwc-aura-or-vf-page-as-tag/
https://developer.salesforce.com/blogs/engineering/2014/04/building-content-rich-visualforce-pages-with-salesforce-crm-content.html


 
<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}" />
<br/>
 </lightning:card>
 </li>
 </aura:iteration>


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

 
sachinarorasfsachinarorasf
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.

Thanks.
Sachin Arora