Skip to content

Commit

Permalink
Check fields.file exists in richTextToHTML filter
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinEtchells committed Aug 16, 2024
1 parent db2cd0b commit f6116ed
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions .eleventy.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ module.exports = function (eleventyConfig) {
target: { fields },
},
}) => {
if (fields.file.url.includes(".mp4")) {
if (fields.file?.url.includes(".mp4")) {
return `
<video class="iai-promo-video" controls preload="auto" aria-describedby="video-desc">
<source src="${fields.file.url}" type="video/mp4" />
Expand All @@ -77,13 +77,13 @@ module.exports = function (eleventyConfig) {
if (fields.title) {
return `
<figure>
<img src="${fields.file.url}" alt="${fields.description}" loading="lazy"/>
<img src="${fields.file?.url}" alt="${fields.description}" loading="lazy"/>
<figcaption>${fields.title}</figcaption>
</figure>
`;
} else {
return `
<img src="${fields.file.url}" alt="${fields.description}" loading="lazy"/>
<img src="${fields.file?.url}" alt="${fields.description}" loading="lazy"/>
`;
}
}
Expand Down

0 comments on commit f6116ed

Please sign in to comment.