Site logo

[Resolved] Featured Image – Maintaining Aspect Ratio on Mobile & Tablet

Home Forums Support [Resolved] Featured Image – Maintaining Aspect Ratio on Mobile & Tablet

Home Forums Support Featured Image – Maintaining Aspect Ratio on Mobile & Tablet

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1773936
    MMS

    Hi, I have tried reducing the height of the featured images via Layout > Blog > Featured Images > Height PX 420 (Desktop). But if I set this for desktop the aspect ratio is wrong for tablet and mobile. The height setting here seems to carry across all 3 Desktop / Tablet / Mobile views. How can I reduce the height of the featured image and maintain the same (or similar) aspect ratio for tablet & mobile views ? Thanks

    #1773961
    David
    Staff
    Customer Support

    Hi there,

    thats correct – the way WP works is using src-set images, which creates various sizes of the Image, but they will all use the same aspect ratio. Various aspect ratios, known as Art Direction isn’t supported in the WP image function so having different ratios can only be achieved with CSS.

    If you want to change the image sizes so they display correctly on mobile, then share a link to your site i can provide some CSS to change them for desktop.

    #1774039
    MMS

    Hi, Thanks my site is https://makemesustainable.com but its in maint mode so you won’t be able to view it unless you log in using the credentials provided below. The Desktop image height is currently set to 420 px Thanks

    #1774452
    David
    Staff
    Customer Support

    Try adding this CSS to remove the fixed ‘height’ on smaller devices:

    @media(max-width: 768px) {
        .resize-featured-image .post-image img {
            height: auto;
            -o-object-fit: unset;
            object-fit: unset;
        }
    }
    #1774458
    MMS

    Hi, Thanks. Works a treat for Mobile view but not for Tablet, is there anything that can be done there ?

    #1774506
    David
    Staff
    Customer Support

    In the first line of the CSS ie.

    @media(max-width: 768px) {

    You can change 768 to 1024 to include Tablet.

    #1774525
    MMS

    Thanks

    #1774554
    David
    Staff
    Customer Support

    You’re welcome

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.