How can I add an icon representing a file type for a URL into a table?
I have a data set which contains a column for URL's for file a user has upload and a second column that contains the type of file that has been uploaded. I have created a beast mode that displays a thumbnail of any uploads that are images. I now want to display an icon for items that are not images but cannot get the icons to display.
This is the beast mode that I have been using to display the thumbnails:
CONCAT('<a href="',`stepAnswerUploadUrl`,'" target="_blank">',
'<img src="',`stepAnswerUploadUrl`,'" height="20px" alt="Click for image"/>',
'</a>')
As a test I attempted to load a PDF icon for all non-image file types, using the following beast mode. The thumbnail worked for images but all other types were blank.
CASE
WHEN stepAnswerUploadType
= 'IMAGE' THEN
CONCAT('<a href="',`stepAnswerUploadUrl`,'" target="_blank">',
'<img src="',`stepAnswerUploadUrl`,'" height="20px" alt="Click for image"/>',
'</a>')
ELSE
CONCAT('<a href="',`stepAnswerUploadUrl`,'" target="_blank">',
'<i class="fas fa-file-pdf"></i>',
'</a>')
END
Any assistance would be greatly appreciated
Best Answer
-
I would probably still create a column that is either the link to the image or a link to an image that represents the file type, and then use that as the image source in the HTML Beastmode. (To me, it's harder to get HTML code right, so I want to keep that part of the code as simple as possible).
But if you want to do it in your case statement, you just need a working img src, which is missing from that clause of your case statement:
CASE
WHENstepAnswerUploadType
= 'IMAGE' THEN
CONCAT('<a href="',`stepAnswerUploadUrl`,'" target="_blank">',
'<img src="',`stepAnswerUploadUrl`,'" height="20px" alt="Click for image"/>',
'</a>')
WHENstepAnswerUploadType
= 'PDF' THEN
CONCAT('<a href="',`stepAnswerUploadUrl`,'" target="_blank">','<img src=https://upload.wikimedia.org/wikipedia/commons/thumb/8/87/PDF_file_icon.svg/267px-PDF_file_icon.svg.png height="20px" alt="Click for file"/>',
'</a>')
ENDPlease 💡/💖/👍/😊 this post if you read it and found it helpful.
Please accept the answer if it solved your problem.
0
Answers
-
I used:
CASE
WHENstepAnswerUploadType
= 'IMAGE' THEN
CONCAT('<a href="',`stepAnswerUploadUrl`,'" target="_blank">',
'<img src="',`stepAnswerUploadUrl`,'" height="20px" alt="Click for image"/>',
'</a>')
WHENstepAnswerUploadType
= 'PDF' THEN
CONCAT('<a href="',`stepAnswerUploadUrl`,'" target="_blank">',
'<img src="',`stepAnswerUploadUrl`,'" height="20px" alt="Click for image"/>',
'</a>')
ENDAnd get the following:
Will that work for you?
If I solved your problem, please select "yes" above
0 -
Thanks for the quick response. Unfortunately that does not work for me. The value in stepAnswerUploadUrl is the url for the actual file that was uploaded not an icon. The image works because it opens a thumbnail of the actual image.
0 -
You're using `stepAnswerUploadUrl` to point towards the image icon and that's working? Why don't you add the url for your PDF icon to that same column so you don't need a CASE statement?
Like all IMAGES, could have this url as their <img src>:
And all PDFs could have this url as their <img src>:
Please 💡/💖/👍/😊 this post if you read it and found it helpful.
Please accept the answer if it solved your problem.
0 -
The stepAnswerUploadUrl contains the url of the actual item that was uploaded to the system not the url for the icon. Ideally, I would want to show a thumbnail of the uploaded file regardless of the file type, but am willing to settle for the icon of the file type if it is not an image.
DaveTestImage contains this beast mode calculation:
CASE
WHENstepAnswerUploadType
= 'IMAGE' THEN
CONCAT('<a href="',`stepAnswerUploadUrl`,'" target="_blank">',
'<img src="',`stepAnswerUploadUrl`,'" height="20px" alt="Click for image"/>',
'</a>')
ELSE
CONCAT('<a href="',`stepAnswerUploadUrl`,'" target="_blank">',
'<i class="fas fa-file-pdf"></i>',
'</a>')
END0 -
I would probably still create a column that is either the link to the image or a link to an image that represents the file type, and then use that as the image source in the HTML Beastmode. (To me, it's harder to get HTML code right, so I want to keep that part of the code as simple as possible).
But if you want to do it in your case statement, you just need a working img src, which is missing from that clause of your case statement:
CASE
WHENstepAnswerUploadType
= 'IMAGE' THEN
CONCAT('<a href="',`stepAnswerUploadUrl`,'" target="_blank">',
'<img src="',`stepAnswerUploadUrl`,'" height="20px" alt="Click for image"/>',
'</a>')
WHENstepAnswerUploadType
= 'PDF' THEN
CONCAT('<a href="',`stepAnswerUploadUrl`,'" target="_blank">','<img src=https://upload.wikimedia.org/wikipedia/commons/thumb/8/87/PDF_file_icon.svg/267px-PDF_file_icon.svg.png height="20px" alt="Click for file"/>',
'</a>')
ENDPlease 💡/💖/👍/😊 this post if you read it and found it helpful.
Please accept the answer if it solved your problem.
0 -
Thanks that does work
0
Categories
- All Categories
- 1.8K Product Ideas
- 1.8K Ideas Exchange
- 1.6K Connect
- 1.2K Connectors
- 300 Workbench
- 6 Cloud Amplifier
- 9 Federated
- 2.9K Transform
- 102 SQL DataFlows
- 626 Datasets
- 2.2K Magic ETL
- 3.9K Visualize
- 2.5K Charting
- 755 Beast Mode
- 61 App Studio
- 41 Variables
- 693 Automate
- 178 Apps
- 456 APIs & Domo Developer
- 49 Workflows
- 10 DomoAI
- 38 Predict
- 16 Jupyter Workspaces
- 22 R & Python Tiles
- 398 Distribute
- 115 Domo Everywhere
- 276 Scheduled Reports
- 7 Software Integrations
- 130 Manage
- 127 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 11 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 110 Community Announcements
- 4.8K Archive