View Source SEO.OpenGraph.Image (SEO v0.1.11)
URL or details for the image. The og:image
property has some optional structured properties:
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
Summary
Functions
Build an OpenGraph image
Attributes
content
(:any
) - Either anSEO.OpenGraph.Image
, a string, or a URI. Defaults tonil
.
Types
Functions
@spec build(SEO.attrs(), SEO.config()) :: t() | nil
Build an OpenGraph image
:url
- Identical toog:image
.:secure_url
- An alternate url to use if the webpage requires HTTPS. If not supplied but:url
starts with "https" then this will be populated with the url as well.: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
.
Attributes
content
(:any
) - Either anSEO.OpenGraph.Image
, a string, or a URI. Defaults tonil
.