Facebook provides a dedicated API to personalize the preview of shared links.
Specifically, the og:image
property allows you to specify the image which will displayed as thumbnail. Populating this tag using a Cloudinary URL will help you to make sure that the image is quickly delivered via CDN and displayed using the appropriate dimensions and composition according to the transformation you have provided.
For example:
<head>
...
<meta property="og:image" content="http://res.cloudinary.com/demo/image/upload/w_100,h_100,c_thumb,g_faces/couple.jpg" />
...
</head>
Comments
6 comments
Oh, got it! That makes sense. Thank you. 🙂
images are not loading on facebook when we share can you please take a look
Can you please share a couple of examples that demonstrate your issue? if you want to keep it private, please feel free to open a support ticket with all the necessary details.
Hi Mirha,
The width parameter is not being reflected in the URL since width/height relies on another parameter being present - "crop" - which controls what type of cropping to apply. You could try to set - crop: "scale" - in your cl_image_path and that will use the "scale" mode and the width and crop mode parameters would be added to the URL.
Please see the below section in the documentation that provides more details on the different crop modes available so that you can find the best one for your requirements (as it may not be "scale" which was just an example) -
https://cloudinary.com/documentation/image_transformation_reference#crop_parameter
I have the following code in Rails. Unfortunately, the width attribute doesn't seem to be taking.
```
<% content_for :meta_image, cl_image_path(@recipe.photo.key, width: 1200, quality: "auto") if @recipe.photo.attached? %>
What am I missing?
@Roee created seperate ticket
Please sign in to leave a comment.