Closed flamedfury closed 11 months ago
@flamedfury Is it possible to add logic to your site to catch if a bookmark doesn't have an image and then show a different image? If so, this may afford you greater flexibility than hardcoding a placeholder image into the dataset.
Here's an example of what that might look like using liquid:
{% for bookmark in bookmarks %}
<img src="{% if bookmark.image %}{{bookmark.image}}{% else %}placeholder.png{% endif %}" alt="{{bookmark.title}}" />
{% endfor %}
Thanks for the tip @katydecorah I'll check this out and report back.
I think that the issue I run into is that the seasonal post frontmatter yaml adds the image into the frontmatter, whether it exists or not in the metadata-library...
e.g. 2023-03-20-2023-summer.md
bookmarks:
- title: 2023, the year of websites
site: Andy Bell
url: https://andy-bell.co.uk/2023-the-year-of-websites/
image: bookmark-2023-the-year-of-websites.jpg
If you check the img
directory in the repo that image doesn't exist, https://github.com/flamedfury/metadata-library/tree/main/img
It also shows it exists in the json file too https://github.com/flamedfury/metadata-library/blob/0be0c56d761fa92984eb7d0b0a53b6507b4739a2/_data/bookmarks.json#LL20C18-L20C18
Does this make sense? Or has my action bugged out?
@flamedfury I do see the image file as .png
and not a .jpg
as shown in your code snippet. Here's the commit the bookmark and image was added: https://github.com/flamedfury/metadata-library/commit/28dd3ab03dd2e7e50ea9b497f4a6b8473156340d
I'm not sure what could have happened where the file extension for that image change during the seasonal-post-action. The action essentially copies over data... 🤔 hmm thinking...
Have you seen other bookmarks with this behavior?
Good catch; I did not notice the difference in the file names. I can't see any others like this.
I can see a few more where the images were missing, but the yaml output still acted like one was there. I've manually edited/removed them from the seasonal post.
They are still missing on the bookmarks page...
{
"title": "A Web that Reflects People and their Val… — Jacky Alciné",
"site": "jackyalciné",
"author": "Jacky Alciné",
"date": "2023-01-30",
"description": "",
"url": "https://jacky.wtf/2022/6/Cpq0?",
"image": "bookmark-a-web-that-reflects-people-and-their-val-jacky-alcin.jpg",
"type": "website",
"notes": "Dive into the current state of the internet and the rise of decentralised projects attempting to offer an alternative to the tech giants. Jacky expresses their desire for an alternative social networking system that allows them to publish and share content while maintaining control over their data. I like emphasising this exact message in every conversation about posting your content online."
},
{
"title": "Smashmouth's White Magic",
"site": "Cool Guy Website",
"author": "Zach Mandeville",
"date": "2023-01-31",
"description": "Older esoteric standup piece",
"url": "https://coolguy.website/smashmouth-white-magic/",
"image": "bookmark-smashmouths-white-magic.png",
"type": "article",
"notes": "Zach dives into Smashmouth's hidden, mystical significance, particularly the references to hermetic alchemy in their music. It hilariously ends with a warning of the dangers of bands like Third Eye Blind, who use the occult arts to obfuscate and block spiritual clarity."
},
{
"title": "The internet is not broken. People are. - Manu",
"site": "Manuel Moreale",
"author": "Manu",
"date": "2023-01-29",
"description": "That magical place that is Hacker News managed to fish up this piece of content today, from the depths of the web. And I am very grateful for that. …",
"url": "https://manuelmoreale.com/the-internet-is-not-broken-people-are",
"type": "",
"notes": ""
}
Would it be possible to use a default/placeholder image for articles/links that are added and do not have an image associated with the post to avoid a broken image when displaying in my template?