Quantcast
Channel: WordPress.org Forums » [Jetpack - WP Security, Backup, Speed, & Growth] Support
Viewing all articles
Browse latest Browse all 37023

Jeremy Herve on "[Plugin: Jetpack by WordPress.com] Photon destroyed "slides" featured images"

$
0
0

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.


Viewing all articles
Browse latest Browse all 37023

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>