• Resolved Tom

    (@godsdead)


    I created 1920×350 banners for my website that work in a slider, they are set via the featured image section, As soon as I activated the Photon addon, it destroyed the dimensions, creating a mess, Im not sure what to do.
    They got resized to 1500px × 273px.
    You can see the messy headers at https://www.piratemc.com

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic ??

    Did you use a specific plugin to add the slider? If so, could you check that width and height attributes are added for each image in the slider?

    Let me know if it helps.

    Thread Starter Tom

    (@godsdead)

    Nope, its built into my theme, Im running an older version of https://www.cpothemes.com/theme/panoramica
    There are no settings, since its set via the featured image section.
    I uploaded a new version to see if there were settings, there are not.

    Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic ??

    I had a look at the theme, and it seems to be using wp_get_attachment_image_src() to get the image, and then resize It. Unfortunately, that won’t work well with Photon, unless you make a few changes.

    Try the following:

    1. In your theme’s functions.php, add the following:
      function godsdead_jetpack_photon_image_downsize_array( $photon_args ) {
      	$photon_args['resize'] = $photon_args['fit'];
      	unset( $photon_args['fit'] );
      
      	return $photon_args;
      }
    2. In your theme’s header.php, locate the following line:

      <?php $image_url = wp_get_attachment_image_src(get_post_thumbnail_id(get_the_ID()), array(1500, 7000), false, ''); ?>

    3. Delete that line, and replace it with the following:
      <?php
      	add_filter( 'jetpack_photon_image_downsize_array', 'godsdead_jetpack_photon_image_downsize_array' );
      	$image_url = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID() ), array(1500, 7000), false, '' );
      	remove_filter( 'jetpack_photon_image_downsize_array', 'godsdead_jetpack_photon_image_downsize_array' );
      ?>

    That should solve the issue.

    Thread Starter Tom

    (@godsdead)

    Thank you so much for going the extra mile looking at the theme and writing this code.
    Superb support.

    Thread Starter Tom

    (@godsdead)

    Thank you so much for going the extra mile to scan through the themes header and write this fix, My wordpress themeing knowledge is limited and wouldn’t have been able to figure this out.
    They even use Photon still which is superb.

    Edit, Looks like that first post took a few seconds to appear! Double reply thanks! haha

    Thread Starter Tom

    (@godsdead)

    Spoke too soon! It works on smaller displays, but when I get to 1920×1080 displays the 1920px images are not spanning the width since the images got resized to 1500px…

    Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic ??

    when I get to 1920×1080 displays the 1920px images are not spanning the width since the images got resized to 1500px…

    I believe that’s the expected behaviour with this theme. Your images won’t be larger than 1500px unless you change that value to something else.

    Thread Starter Tom

    (@godsdead)

    Nope, I had all the images at the resolution I uploaded them as working fine in the slider before photon.
    Would a fix be as simple as changing the 1500 in this to 1920?

    <?php
    	add_filter( 'jetpack_photon_image_downsize_array', 'godsdead_jetpack_photon_image_downsize_array' );
    	$image_url = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID() ), array(1500, 7000), false, '' );
    	remove_filter( 'jetpack_photon_image_downsize_array', 'godsdead_jetpack_photon_image_downsize_array' );
    ?>

    Thread Starter Tom

    (@godsdead)

    Yeah that fixed it.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Photon destroyed "slides" featured images’ is closed to new replies.