View Source SEO.OpenGraph.Image (SEO v0.1.2)

URL or details for the image. The og:image property has some optional structured properties:

  • :url - Identical to og:image.
  • :secure_url - An alternate url to use if the webpage requires HTTPS.
  • :type - A MIME type for this image.
  • :width - The number of pixels wide.
  • :height - The number of pixels high.
  • :alt - A description of what is in the image (not a caption). If the page specifies an image it should also specify :alt.

NOTE: to update an image after it's been published, use a new URL for the new image. Images are typically cached based on the URL and won't be updated unless the URL changes. In Phoenix, the URL is typically using a hashed version of the image (see mix phx.digest), so this should be handled automatically.

Best practices:

  • Use images that are at least 1080 pixels in width for best display on high resolution devices. At the minimum, you should use images that are 600 pixels in width to display image link ads. We recommend using 1:1 images in your ad creatives for better performance with image link ads.
  • Pre-cache your images by running the URL through the URL Sharing Debugger tool to pre-fetch metadata for the website. You should also do this if you update the image for a piece of content.
  • Use :width and :height to specify the image dimensions to the crawler so that it can render the image immediately without having to asynchronously download and process it.

Resources

Link to this section Summary

Functions

Attributes

Link to this section Types

@type mime() :: String.t()
@type pixels() :: pos_integer()
@type t() :: %SEO.OpenGraph.Image{
  alt: String.t(),
  height: pixels(),
  secure_url: URI.t() | String.t(),
  type: mime(),
  url: URI.t() | String.t(),
  width: pixels()
}

Link to this section Functions

Link to this function

build(attrs, default \\ nil)

View Source

attributes

Attributes