Skip to content

Commit

Permalink
Merge pull request #8 from CloudCannon/fix/empty-image-src
Browse files Browse the repository at this point in the history
Feat: empty image check
  • Loading branch information
Tiaan-CC authored Nov 12, 2024
2 parents 6a418eb + 3bd5c12 commit 40ce4b8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
2 changes: 1 addition & 1 deletion component-library/components/cards/cards.eleventy.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{% for card in cards %}
<div class="card">
<div class="media">
{% image card.media.url card.media.alt 500 %}
{% image card.media.image.url card.media.image.alt 500 %}
</div>
<div class="text">
<h3>
Expand Down
2 changes: 1 addition & 1 deletion eleventy.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = function(eleventyConfig) {
eleventyConfig.addPlugin(svgContents);

eleventyConfig.addShortcode("image", async function (src, alt, widths, sizes) {
if (src === undefined) {
if (src === undefined || src === null) {
return "";
}

Expand Down
18 changes: 6 additions & 12 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,24 @@
cards:
- media:
image:
url: ''
alt: ''
url: /assets/campus.jpg
alt: Campus
url: /assets/campus.jpg
alt: Campus
heading:
text: Admissions
url: '#'
text: Learn more about the admissions process and how to apply.
- media:
image:
url: ''
alt: ''
url: /assets/lecture.jpg
alt: Lecture hall
url: /assets/lecture.jpg
alt: Lecture hall
heading:
text: Academics
url: '#'
text: Explore our academic programs and departments.
- media:
image:
url: ''
alt: ''
url: /assets/research.jpg
alt: Research lab
url: /assets/research.jpg
alt: Research lab
heading:
text: Research
url: '#'
Expand Down

0 comments on commit 40ce4b8

Please sign in to comment.