Skip to content

Commit

Permalink
[BUGFIX] Always render og:image if news has at least one image (#2510)
Browse files Browse the repository at this point in the history
* [BUGFIX] Always render og:image if news has at least one image

Fixes: #2509

* [TASK] Prioritize preview image over other images

Fixes: #2509
  • Loading branch information
peterkraume committed Jul 31, 2024
1 parent b0a2d72 commit 2ea5872
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion Resources/Private/Partials/Detail/Opengraph.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,18 @@
<n:metaTag property="og:type" content="{settings.opengraph.type}" />
<n:metaTag property="og:url" content="" useCurrentDomain="1" />
<n:metaTag property="og:site_name" content="{settings.opengraph.site_name}" />

<f:if condition="{newsItem.firstPreview}">
<f:variable name="ogImagePath" value="{f:uri.image(src:'{newsItem.firstPreview.uid}', treatIdAsReference:1, maxWidth:'1200')}" />
<f:then>
<f:variable name="ogImage" value="{newsItem.firstPreview}" />
</f:then>
<f:else if="{newsItem.falMedia}">
<f:variable name="ogImage" value="{newsItem.falMedia.0}" />
</f:else>
</f:if>

<f:if condition="ogImage">
<f:variable name="ogImagePath" value="{f:uri.image(src:'{ogImage.uid}', treatIdAsReference:1, maxWidth:'1200')}" />
<n:metaTag
property="og:image"
content="{ogImagePath}"
Expand Down

0 comments on commit 2ea5872

Please sign in to comment.