Skip to content

Commit

Permalink
Added missing image support to search results
Browse files Browse the repository at this point in the history
  • Loading branch information
davidjgonzalez committed Jul 22, 2024
1 parent 5bd7171 commit 1e54730
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,14 @@
style="height:${height @ context = 'styleToken'}px;"
controls controlsList="nodownload"
data-sly-test.height="${properties['height']}">
<source src="${video.src}"
type="video/webm"/>
<source src="${video.src}"
type="video/mp4"/>

<source src="${video.src}" />
</video>

<!--/* Video element without a max height */-->
<video class="ui centered image cmp-image"
poster="${properties['posterImage']}" controls controlsList="nodownload"
data-sly-test="${!height}">
<source src="${video.src}"
type="video/webm"/>
<source src="${video.src}"
type="video/mp4" />
<source src="${video.src}"/>
</video>

</template>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#base=js

scripts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
document.addEventListener('DOMContentLoaded', function() {
const images = document.querySelectorAll('img[data-asset-share-missing-image]');
images.forEach(img => {
img.onerror = function() {
this.src = this.getAttribute('data-asset-share-missing-image');
};
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
class="cmp-image--card"
width="237px"
height="175px"
data-asset-share-missing-thumbnail="${properties['missingImage']}"
alt="${asset.properties['title']}"/>
</a>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<a class="cmp-card__link" href="${assetDetails.url @ suffix = asset.path}">
<img src="${asset.properties['rendition?name=card'] || properties['missingImage'] @ context = 'attribute'}"
class="cmp-card__image"
data-asset-share-missing-thumbnail="${properties['missingImage']}"
alt="${asset.properties['title']}"/>
</a>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
<td class="image">
<a href="${assetDetails.fullUrl}"><img src="${asset.properties['rendition?name=list'] || properties['missingImage'] @ context = 'attribute'}"
width="98px"
data-assets-share-missing-thumbnail="${properties['missingImage']}"
alt="${asset.properties['title']}"/></a>
</td>
<td class="header">
Expand Down

0 comments on commit 1e54730

Please sign in to comment.