Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #981125

    Situation:
    All the images I use for the the Featured Image have a default size of 865 × 280.

    Today I uploaded a Featured Image with the same size, but it is rendered 305×211.
    All the other featured images are rendered 355×115
    Also the other featured images are showed in a more advance srcset

    https://greywise.redfactory.nl/cases/

    Has this something to do with a configuration or a theme update?

    • This topic was modified 6 years, 4 months ago by tijshensen.
    #981985

    Hey tijshensen,

    Thank you for using Enfold.

    This filter should alter the default sizes attribute based on the current thumbnail.

    /**
     * Set sizes atribute for responsive images and better performance
     * @param  array        $attr       markup attributes
     * @param  object       $attachment WP_Post image attachment post
     * @param  string|array $size       named image size or array
     * @return array        markup attributes
     */
    function avf_responsive_img_sizes( $attr, $attachment, $size ) {
        if ( is_array( $size ) ) {
            $attr['sizes'] = $size[0] . 'px';
        } elseif ( $size == 'widget') {
            $attr['sizes'] = '36px';
        } elseif ( $size == 'square') {
            $attr['sizes'] = '180px';
        } elseif ( $size == 'featured') {
            $attr['sizes'] = '1500px';
        } elseif ( $size == 'featured_large') {
            $attr['sizes'] = '1500px';
        } elseif ( $size == 'extra_large' ) {
            $attr['sizes'] = '1500px';
        } elseif ( $size == 'portfolio' ) {
            $attr['sizes'] = '495px';
        } elseif ( $size == 'portfolio_small' ) {
            $attr['sizes'] = '260px';
        } elseif ( $size == 'gallery' ) {
            $attr['sizes'] = '845px';
        } elseif ( $size == 'magazine' ) {
            $attr['sizes'] = '710px';
        } elseif ( $size == 'masonry' ) {
            $attr['sizes'] = '705px';
        } elseif ( $size == 'entry_with_sidebar' ) {
            $attr['sizes'] = '845px';
    	} elseif ( $size == 'entry_without_sidebar' ) {
            $attr['sizes'] = '1210px';
        }
        return $attr;
    }
    add_filter( 'wp_get_attachment_image_attributes', 'avf_responsive_img_sizes', 30, 3 );

    Let us know if it helps.

    Best regards,
    Ismael

    #983119

    The ‘portfolio’ size seams correct.
    But in the original thumbnails it’s scaled back to 495px X 160px. Where the new thumbnails are cropped 495px X 280px.

    So when/where does the cropping takes place and how can I avoid cropping?

    #983951

    Hi,

    Thanks for the update.

    Where can I see the issue again? The thumbnails’ size are 355x116px when I checked the page.

    So when/where does the cropping takes place and how can I avoid cropping?

    The cropping takes place as soon as the images are uploaded. There’s also a function or script that automatically selects the appropriate size or thumbnail based on the current screen size or resolution which is why we added the filter above.

    // https://make.wordpress.org/core/2015/11/10/responsive-images-in-wordpress-4-4/

    Best regards,
    Ismael

    #985133

    Thanks for your reply.
    We decided to create a new overview pages. I think part of the problem lies in the fact that the previous ‘portfolio’ images where cropped in another way then the Enfold theme does.

    #985810

    Hi,

    Alright. Let us know if you need anything else. Just open a new thread. :)

    Best regards,
    Ismael

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Featured image with the same dimension shows different thumb in blog overview’ is closed to new replies.