Skip to content

Support Letterbox transforms. notably for social sharing (but I'd argue should be the defaut mode...) #1337

Closed
@bossanova808

Description

@bossanova808

Without a proper support for fit image, it's basically impossible to use existing image content (e.g. a product's master image) in an appropriate way for social shares - i.e. none of the Craft transform modes produce the desired result of an actual image fit.

Craft, since 4.4, offers a new 'Letterbox' transform mode, that is akin to 'fit image' in most image processing programs, i.e. both the height and width are made to fit within the given bounds.

Craft chooses to pad this image it seems, and for reasons I can't really understand, seems to default to padding with black.

I hacked support into facebook-og-image-partial.twig :

    {% set imageCropModes = {
        "crop": "Crop"|t("seomatic"),
        "fit": "Fit"|t("seomatic"),
        "stretch": "Stretch"|t("seomatic"),
        "letterbox": "Letterbox",
    } %}

This improves things a lot, but needs white padding (by default), possible selectable - and isn't quite all the way there, if the preview is accurate:

'Fit' selected:

image

'Letterbox' selected - I am unsure why this still gets cropped TBH:

image

It would be really great to have a solve for this issue, it's been bugging me for years now - every time I see a share of one of our things go past and the image is all messed up, it makes an SEO fairy somewhere fall out of the sky, and die.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions