Ecommerce Shopify WordPress Discussion

Exclude specific images size from jetpack site accelerator (photon) [closed]

Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 2 days ago. Improve this question I want to exclude images that are over 15000px in height (only cache images down 15000px) on wordpress photon I found this article from jetpack that can help to do that but, I don't know how to code so I don't have an idea what I should do. Any can make it for me? This from the article function my_photon_exception( $val, $src, $tag ) { if ( $src == 'YOUR_IMAGE_URL' ) { return true; } return $val; } add_filter( 'jetpack_photon_skip_image', 'my_photon_exception', 10, 3 ); I think ( $src == 'YOUR_IMAGE_URL' ) should be replaced with something define image height (15000px or over) but I don't know what to type instead of it.
Identify the Image Size: First, identify the specific image size(s) you want to exclude. WordPress image sizes are typically defined in your theme’s functions.php file using add_image_size(). Use jetpack_photon_skip_image Filter: Jetpack provides a filter jetpack_photon_skip_image which allows you to control whether an image should be served by the Site Accelerator or not. You can use this filter to check the image size and decide whether to exclude it. function wpb_exclude_specific_image_size_from_photon($skip, $image_url, $args) { // Check if the specific image size is in the URL if (strpos($image_url, '-custom-size.jpg') !== false) { // Replace '-custom-size.jpg' with your image size identifier return true; // Skip this image size from Photon } return $skip; } add_filter('jetpack_photon_skip_image', 'wpb_exclude_specific_image_size_from_photon', 10, 3); If you need to see the different size images in your site use this code: function wpb_get_image_sizes( $image_id ) { $sizes = get_intermediate_image_sizes(); $images = array(); foreach ( $sizes as $size ) { $image = wp_get_attachment_image_src( $image_id, $size ); $images[$size] = array( 'url' => $image[0], 'width' => $image[1], 'height' => $image[2] ); } return $images; } You can also find the image sizes your site offers by going to the media library: Media Library List View: Go to your WordPress dashboard. Navigate to Media > Library. Switch to the 'List View' (if you are in the 'Grid View'). Click on an image to open its 'Attachment Details' screen. Here, you can see the dimensions of the original uploaded image. However, this view does not typically show the dimensions of all different image sizes that WordPress generates. You can also ftp into your site and go to your uploads folder, then into a folder with the year, then month, etc. Once you are there it shows the files that were uploaded with the sizes. You can get your information there as well.

December 29, 2023

TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.