display attachment in lightning component by w3web.net

How to display upload Image if a record existing an attachment in lightning component? | how to display image icon in lightning component from attachment

176 views

Hey guys, In this post we are going to learn about how to Display an Upload Icon on the lightning component if a object record has files or any kind of attachment..

Requirement:- If upload a custom file on lightning component such like (jpg’, ‘jpeg’,’pdf’, ‘doc’) etc.. then against of every record display should be an attachment Image on right side of table.

Files we used in this post example:-

fileAttachmentCmp.cmp Lightning Component It is used for display the name, address, email, and upload file button on the table.
fileAttachmentCmpConroller.js JavaScript Controller File It is used for communicate to server side apex method and fetch the record using init fuction.
fileAttachmentCmpHelper.js JavaScript Helper File It is used for refresh the page after delete the record.
wrapperCustomObjCtrCmp.apxc Apex Class Controller It is used for save the upload images on sObject database.

Custom Object:- NewStudent__c

Custom Object Fields:-

Name,

Email__c

Address__c

Custom Object and their fields Display an upload Image on right side of table in the lightning component if a record has an attachment.

Final Output

display attachment image in lightning component -- w3web.net

Other related post that would you like to learn in lightning component.

Step 1:- Create Lightning Component : fileAttachmentCmp.cmp

From Developer Console >> File >> New >> Lightning Component

fileAttachmentCmp.cmp [Lightning Component File]

Step 2:- Create Lightning Component : fileAttachmentCmpConroller.js

From Developer Console >> File >> New >> Lightning Component >> JavaScript Controller

fileAttachmentCmpConroller.js [JavaScript Controller]

Step 3:- Create Lightning Component : fileAttachmentCmpHelper.js

From Developer Console >> File >> New >> Lightning Component >> JavaScript Helper

fileAttachmentCmpHelper.js [JavaScript Helper File]

display attachment in lightning component by w3web.net

Step 4:- Create Lightning Application : wrapperCustomObjCtrCmp.apxc

From Developer Console >> File >> New >> Apex Class

wrapperCustomObjCtrCmp.apxc [Apex Class Controller]

 

Further post that would you like to learn in lightning component.

 

 

 

FAQ (Frequently Asked Questions)

How do you display an image in the lightning component?

To display images, use the HTML 'img' element. Include an image in your component by uploading it as a static resource or content asset.To display an icon, use the lightning:icon component, which gives you access to Salesforce Lightning Design System icons or your own custom icon.

How do I preview files in lightning component?

A lightning:fileCard component displays a preview of a file. On desktops, clicking the file preview opens the SVG file preview player, enabling you to preview images, documents, and other files in the browser. The file preview player provides quick access to file actions, such as upload, delete, download, and share.

What is lightning out?

Lightning Out is a technology where one can take Lightning components built on the Force.com platform to the external applications like Sharepoint, SAP, Node apps on Heroku and many others.

  • Your reaction of the article β–Ύ
 

Hi, This is Vijay Kumar behind the admin and founder of w3web.net. I am a senior software developer and working in MNC company from more than 8 years. I am great fan of technology, configuration, customization & development. Apart of this, I love to write about Blogging in spare time, Working on Mobile & Web application development, Salesforce lightning, Salesforce LWC and Salesforce Integration development in full time. [Read full bio] | | The Sitemap where you can find all published post on w3web.net

15 thoughts on “How to display upload Image if a record existing an attachment in lightning component? | how to display image icon in lightning component from attachment”

Leave a Comment