How to produce OG tags for image height, width and type

Created on 7 July 2023, over 1 year ago

Problem/Motivation

I've tried with v1.2.1, 1.2.6 and 2.0.0 to produce the OG tags for image width, height and type, using, in the case of width, each of:

  • [node:field_page_hero_img:entity:field_media_image:entity:width]
  • [node:field_page_hero_img:entity:field_media_image:width]
  • [node:field_page_hero_img:entity:media:field_media_image:entity:width]
  • [node:field_page_hero_img:width]

In the Image widthfield for the content type's OG tags settings. While the first bullet works with :url for the image, itself, nothing seems to generate a tag at all, let alone populated, for the image attributes in their respective settings.

Steps to reproduce

Enter [node:IMAGE_FIELD_NAME:entity:MEDIA_IMAGE_FIELD_NAME:entity:width] or
[node:IMAGE_FIELD_NAME:entity:MEDIA_IMAGE_FIELD_NAME:width]
in the Image width OG tag field and check page source when the page is reloaded.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

πŸ“Œ Task
Status

Active

Version

2.0

Component

Documentation

Created by

πŸ‡ΊπŸ‡ΈUnited States j. ayen green

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @j. ayen green
  • πŸ‡ΊπŸ‡ΈUnited States j. ayen green

    I'm going to solve this myself. It seems the best place in this case to get the token format is from admin help for tokens rather than the places I've found suggestions.

    The format that works is:

    [node:FIELD_NAME:entity:MEDIA_FIELD_NAME:STYLE_NAME:height]
    [node:FIELD_NAME:entity:MEDIA_FIELD_NAME:STYLE_NAME:width]
    [node:FIELD_NAME:entity:MEDIA_FIELD_NAME:STYLE_NAME:mimetype]

  • Status changed to Needs review over 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States j. ayen green
  • Status changed to Active over 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States DamienMcKenna NH, USA

    Yeah, it can be really frustrating to find the right token for a given scenario. There's another issue that might help ( ✨ Add link to tokens help page to find the right token Active ) but I think we should add more documentation with suggestions on how to do this.

  • πŸ‡ΊπŸ‡ΈUnited States j. ayen green

    Damien, the remote video url seems to defy attempts, though. The admin help shows the two URL subfields with a remote video field:
    [node:NODE_FIELD:entity:field_media_remote_video_url]
    [node:NODE_FIELD:entity:field_media_oembed_video]

    Neither produce a URL. Not sure if it's a token issue or a metatag one.

Production build 0.71.5 2024