Adding og:image to calendar if one is provided

frm

Well-Known Member
The basic setup for this is to edit the template nf_calendar_event_view and find/replace this:
HTML:
<xf:macro template="metadata_macros" name="metadata"
    arg-description="{$descSnippet}"
    arg-shareUrl="{{ link('canonical:events', $event) }}"
    arg-canonicalUrl="{{ link('canonical:events', $event) }}"/>
With:
HTML:
<xf:comment>Use cover image if selected</xf:comment>
<xf:if is="$event.cover_image_id">
<xf:macro template="metadata_macros" name="metadata"
    arg-description="{$descSnippet}"
    arg-shareUrl="{{ link('canonical:events', $event) }}"
    arg-canonicalUrl="{{ link('canonical:events', $event) }}"
    arg-imageUrl="{{ link('canonical:events/cover-image', $event) }}"
    arg-twitterCard="summary_large_image" />
<xf:else />
    <xf:macro template="metadata_macros" name="metadata"
        arg-description="{$descSnippet}"
        arg-shareUrl="{{ link('canonical:events', $event) }}"
        arg-canonicalUrl="{{ link('canonical:events', $event) }}"/>
</xf:if>
You can use a 'default' cover image by editing the second macro (after <xf:else />) and add:

HTML:
    arg-imageUrl="https://www.yourdomain.com/default-cover-photo.jpg"
    arg-twitterCard="summary_large_image" />
Hopefully, @NixFifty adds this to B5/a stable release, but if not, this will make your events sharable and more click-worthy.
 

NixFifty

Administrator
Staff member
You can actually simplify it down to this:
HTML:
<xf:macro template="metadata_macros" name="metadata"
    arg-description="{$descSnippet}"
    arg-shareUrl="{{ link('canonical:events', $event) }}"
    arg-canonicalUrl="{{ link('canonical:events', $event) }}"
    arg-imageUrl="{{ $event.CoverImage ? link('canonical:events/cover-image', $event) : '' }}"
    arg-twitterCard="summary_large_image" />
Moot point since I've added it in the next release.
 
  • Like
Reactions: frm

frm

Well-Known Member
You can actually simplify it down to this:
HTML:
<xf:macro template="metadata_macros" name="metadata"
    arg-description="{$descSnippet}"
    arg-shareUrl="{{ link('canonical:events', $event) }}"
    arg-canonicalUrl="{{ link('canonical:events', $event) }}"
    arg-imageUrl="{{ $event.CoverImage ? link('canonical:events/cover-image', $event) : '' }}"
    arg-twitterCard="summary_large_image" />
Moot point since I've added it in the next release.
Thanks :)
 
Top