craft-seomatic icon indicating copy to clipboard operation
craft-seomatic copied to clipboard

Twitter preview not showing `fit` tranforms correctly

Open bossanova808 opened this issue 5 years ago • 15 comments

Ok, so I have a portrait orientation image, and with both Twitter and Facebook set to fit, which should (according to Craft docs):

Fit – Scales the image so that it is as big as possible with all dimensions fitting within the specified width and height.

Then I would expect the preview image to show the image completely fit inside the box with whitespace around the left and right edges. However this is what shows:

image

..the Facebook image is as expected, but the Twitter image is shown incorrectly as cropped, though.

I have not dug into how this all works, but I do note that if I change the css property for

.TwitterCard-image-wrapper {
   ...
    background-size: cover
}

to

.TwitterCard-image-wrapper {
   ...
    background-size: contain
}

Then the display is as I'd expect (except maybe the background tone should be white and not grey?):

image

(More than likely this is just an issue with how the preview shows, and the actual image served to Twitter is correctly scaled, but I don't know for sure as this isn't live yet...)

bossanova808 avatar Mar 27 '19 03:03 bossanova808

Can you tell me if it is just the preview that appears to be wrong, or the actual tweeted image that appears to be wrong?

khalwat avatar Apr 01 '19 22:04 khalwat

Not really until I launch this version (~ a month from now) - and actually tweet something out...but no probs coming back to it then if that works for you?

bossanova808 avatar Apr 01 '19 22:04 bossanova808

This works using Craft's concept of "fit" which may not be what we intuitively think it should be. But sure, lmk

khalwat avatar Jun 14 '19 01:06 khalwat

It's the actual tweet too:

image

(from https://imagescience.com.au/products/calibrators/x-rite-i1display-pro)

bossanova808 avatar Jun 14 '19 01:06 bossanova808

I'm having a similar issue. It seems as if the "SEO Image Transform Mode" field is having no effect.

Ω 2019-06-25 at 4 30 12 PM

It seems like whichever option I choose, the image just gets cropped...

Twitter: Ω 2019-06-25 at 4 27 48 PM

Discord: Ω 2019-06-25 at 4 25 05 PM

Slack: Ω 2019-06-25 at 4 31 28 PM

Is this a bug? Or should I be selecting a different option?


SEOmatic: 3.2.9 Craft: 3.1.31

lindseydiloreto avatar Jun 26 '19 17:06 lindseydiloreto

Looking at the code being generated by SEOmatic, it seems like the "Fit" selection is being ignored by the meta tags. Both of these tags are apparently using the crop method.

<meta content=".../_1200x630_crop_center-center_82_none/..." property="og:image">
<meta name="twitter:image" content=".../_800x418_crop_center-center_82_none/...">

Although oddly, the JSON seems to be respecting the fit method...

"image":{"@type":"ImageObject","url":".../_1200x630_fit_center-center_82_none/..."}

lindseydiloreto avatar Jun 26 '19 17:06 lindseydiloreto

So probably you need to set it to fit for Twitter and Facebook too @lindseydiloreto ?

As for it affecting the tweet as well as the preview... Craft's idea of "fit" is that both dimensions of the image fit into what you pass in.

Twitter will crop anything passed in that is not the exact proportions that it's looking for, so the preview is accurate.

What you'd need to do what you think you want would be something that made an image of the exact dimensions passed in, and letterboxed your actual image.

khalwat avatar Jun 26 '19 19:06 khalwat

The Twitter and Facebook ones just say "Same As SEO Image":

Ω 2019-06-26 at 12 44 57 PM Ω 2019-06-26 at 12 45 16 PM

lindseydiloreto avatar Jun 26 '19 19:06 lindseydiloreto

Yep, I think that's a bug @lindseydiloreto -- or at least not what I'd expect either. Go ahead and change those, and explicitly set the transform type

But it's not going to change how it appears on Twitter unfortunately.

On Facebook, it'll look okay.

khalwat avatar Jun 26 '19 19:06 khalwat

Looks like that worked. Thanks @khalwat!

lindseydiloreto avatar Jun 26 '19 19:06 lindseydiloreto

That other issue is over here @lindseydiloreto https://github.com/nystudio107/craft-seomatic/issues/366

khalwat avatar Jun 27 '19 14:06 khalwat

Looks like I have the same issue. No matter what I choose—specific to either the Twitter or FB image or in General—the image gets cropped. Since I'm working with book covers, that's a problem. I'd rather have them 'fit' with white space on left/right. But no matter what I chance, the image remains the same in the preview. ![Screen Shot 2020-03-02 at 13 30 53] Screen Shot 2020-03-02 at 13 32 13 (https://user-images.githubusercontent.com/1124514/75719708-1a9d9a80-5c8a-11ea-9d01-00d8c41519b0.png)

circa42 avatar Mar 02 '20 21:03 circa42

Expected result: expectedresult

circa42 avatar Mar 03 '20 20:03 circa42

Actual result: actual

circa42 avatar Mar 03 '20 20:03 circa42

Ok so do we need to petition P&T for a "Contain" mode? I can not imagine any situation where "fit" would be desirable in this use case, but this is how it seems to work intentionally. Despite it being counter intuitive.

MattWilcox avatar Oct 13 '21 21:10 MattWilcox