Plugin Contributor
Ryan C.
(@ryancowles)
Hi there! Could you please provide us with the entire contents of your functions.php file? You can use a site like GitHub or Pastebin to share your code:
https://gist.github.com/
http://pastebin.com/
If you want it to remain private, you can contact us via this contact form:
http://jetpack.me/contact-support/
Please make sure to include a link to this thread in your message!
Thread Starter
eloylb
(@eloylb)
Hi,
Here’s the link to the functions.php file
https://gist.github.com/4be7a46b8f74ced8ebc3.git
Thanks
I don’t seem to see any Photon changes in that file at the moment:
https://gist.github.com/anonymous/4be7a46b8f74ced8ebc3
Did you remove them?
Thread Starter
eloylb
(@eloylb)
Hi Yes I removed them because of the issues I was facing
Thread Starter
eloylb
(@eloylb)
If I change the last statement below in functions.photon.php from [$arg] to ‘fit’ will all my photos that get passed through photon will get the fit action?
if ( is_array( $args ) ){
// Convert values that are arrays into strings
foreach ( $args as $arg => $value ) {
if ( is_array( $value ) ) {
$args[$arg] = implode( ‘,’, $value );
It will be
if ( is_array( $args ) ){
// Convert values that are arrays into strings
foreach ( $args as $arg => $value ) {
if ( is_array( $value ) ) {
$args[‘fit’] = implode( ‘,’, $value );
}
}
If I change the last statement below in functions.photon.php
I’d recommend against editing plugin files, as your changes will be overwritten when you update the plugin.
Could you post the whole code you’ve added to your theme’s functions.php, via Pastebin or Gist?
Thanks!
Thread Starter
eloylb
(@eloylb)
// If you didn't define a post thumnail, let's forget about all this
if ( !has_post_thumbnail( $post->ID ) )
return $content;
// What's the cropping and the size of image we should use on Single pages?
// See http://developer.wordpress.com/docs/photon/api/#crop for parameters
if ( is_single() ) {
$args = array(
'fit' => '50,50,200px,200px',
);
}
// resizing on other pages
else {
$args = array(
'fit' => '200,400',
);
}
// Let's create a Photon Image URL from the Post Thumbnail
$feat_image_url = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full');
$photon_image_url = jetpack_photon_url( $feat_image_url[0], $args );
// Let's build the image tag
$our_image = sprintf( '<div class="post-media"><a href="%1$s" title="%2$s"><img src="%3$s" class="wp-post-image" alt="Featured Image"></a></div>',
esc_url( get_permalink() ),
esc_attr( sprintf( __( 'Open %s', 'dot' ), get_the_title() ) ),
esc_attr( $photon_image_url )
);
// Let's return the image, right before the post content
return $our_image . $content;
}
add_filter( 'the_content', 'jeherve_display_custom' );
That code won’t change the ways your images are currently cropped. It will only add a new image before the post content, if you’ve defined a Featured Image, and that image will have a custom crop.
If you’d like to have Photon apply some custom cropping to some of your existing post images, you’ll need to edit your theme to use jetpack_photon_url
and custom arguments when returning the image.
I hope this helps.