Plugin Directory

Changeset 3276044


Ignore:
Timestamp:
04/17/2025 04:06:30 PM (10 months ago)
Author:
optimole
Message:

Update to version 4.0.1 from GitHub

Location:
optimole-wp
Files:
22 edited
1 copied

Legend:

Unmodified
Added
Removed
  • optimole-wp/tags/4.0.1/CHANGELOG.md

    r3272237 r3276044  
     1##### [Version 4.0.1](https://github.com/Codeinwp/optimole-wp/compare/v4.0.0...v4.0.1) (2025-04-17)
     2
     3Fix extraneous quotation mark in image URL when changing fetchpriority. 
     4Fix resize behavior for certain image sizes that were improperly resized.
     5
    16#### [Version 4.0.0](https://github.com/Codeinwp/optimole-wp/compare/v3.14.1...v4.0.0) (2025-04-14)
    27
  • optimole-wp/tags/4.0.1/README.md

    r3272237 r3276044  
    33**Tags:** image optimization, convert webp, image optimizer, lazy load, image, optimisation, convert AVIF, resize, free cdn, compress images, optimize images 
    44**Requires at least:** 5.5 
    5 **Tested up to:** 6.7 
     5**Tested up to:** 6.8 
    66**Requires PHP:** 7.4 
    7 **Stable tag:** 4.0.0 
     7**Stable tag:** 4.0.1 
    88**License:** GPLv3 
    99**License URI:** https://www.gnu.org/licenses/gpl-3.0.en.html 
     
    248248## Changelog ##
    249249
    250 #### [Version 4.0.0](https://github.com/Codeinwp/optimole-wp/compare/v3.14.1...v4.0.0) (2025-04-14)
    251 
    252 ### New Features
    253 
    254 - Added [client-side detection](https://docs.optimole.com/article/1948-bypass-lazy-load-for-first-images) of above-the-fold images with device-specific lazy loading for improved performance on both desktop and mobile.
    255 - Introduced [video](https://docs.optimole.com/article/2254-how-to-use-optimole-video-integration) integration that allows uploading, managing, and displaying videos directly via the Optimole DAM.
    256 - Enabled rename and replace functionality for media files within both the WordPress media library and the Optimole Cloud Library.
    257 - Simplified compression settings with [presets](https://docs.optimole.com/article/2252-choose-the-best-optimization-preset-for-your-website) for Speed and Quality optimized workflows.
    258 - Added a download button in the Optimole Cloud Library for quick image retrieval.
    259 - Introduced a WordPress dashboard widget showing visits, optimizations, and latest media activity.
    260 - Launched a [referral](https://docs.optimole.com/article/2253-referral-program) program where each referral grants 500 extra visits, up to 5,000.
    261 - Added support to host and serve PDFs from the Optimole.
    262 - Added support for JPEG XL format
    263 
    264 ---
    265 
    266 ### Enhancements
    267 
    268 - Added direct access to the Optimole Cloud Library from the plugin settings for faster navigation.
    269 - Redesigned the plugin dashboard layout to make metrics clearer and easier to read.
    270 - Enhanced Optimole badge settings with position options and icon-only display mode.
    271 - Added sorting options in the Cloud Library to organize media by upload time or file size.
    272 - Refreshed the first plugin screen with improved trust-building elements.
    273 - Enhanced image preloading logic to more accurately detect and prioritize visible images.
    274 - Displayed clear warnings when free users are approaching their offload limits.
    275 - Added slider navigation and persistent folder state to the Cloud Library for a better media browsing experience.
    276 - Displayed offload quota usage directly in the plugin dashboard.
    277 
    278 ---
    279 
    280 ### Bug Fixes
    281 
    282 - Fixed pixelated SVGs by ensuring proper format is served.
    283 - Prevented redirect issues when rolling back offloaded images in the media library.
    284 - Respected custom image dimensions set in Elementor sliders during auto-scaling.
    285 - Stopped misidentification of mega menu images as hero images.
    286 - Prevented broken links when editing cloud-only images by redirecting to the Optimole Library.
    287 - Preserved original image URLs in Gutenberg when lazy load and scaling are disabled.
    288 - Fixed issue where product gallery images from the Cloud Library also appeared in product descriptions.
    289 - Resolved incorrect quota display for disabled accounts with badge enabled.
    290 - Ensured first-time DAM authorization works across all browsers.
    291 - Corrected sorting so newest uploads appear at the top of the Cloud Library.
    292 - Cleared cache automatically when images are updated on the site.
    293 - Made update and delete buttons for watermarks visible when multiple rows exist.
    294 - Clarified that excluding an image from optimization also excludes it from lazy loading.
    295 - Stopped image distortion when no size attributes are present and scaling is disabled.
    296 - Synced folder tree view and search in the Cloud Library for consistent navigation.
     250##### [Version 4.0.1](https://github.com/Codeinwp/optimole-wp/compare/v4.0.0...v4.0.1) (2025-04-17)
     251
     252Fix extraneous quotation mark in image URL when changing fetchpriority. 
     253Fix resize behavior for certain image sizes that were improperly resized.
    297254
    298255
  • optimole-wp/tags/4.0.1/inc/app_replacer.php

    r3272237 r3276044  
    222222     * @return array Size mapping.
    223223     */
    224     protected static function size_to_crop() {
     224    public static function size_to_crop() {
    225225        if ( ! empty( self::$size_to_crop ) ) {
    226226            return self::$size_to_crop;
     
    615615        } else {
    616616            $optimized_args = $this->parse_dimension_from_optimized_url( $src );
    617             if ( $optimized_args[0] !== 'auto' || $optimized_args[1] !== 'auto' ) {
     617            if ( $optimized_args[0] !== false || $optimized_args[1] !== false ) {
    618618                return [
    619619                    $optimized_args[0] !== 'auto' ? (int) $optimized_args[0] : false,
  • optimole-wp/tags/4.0.1/inc/dam.php

    r3272237 r3276044  
    6666        add_filter( 'image_downsize', [ $this, 'catch_downsize' ], 10, 3 );
    6767        add_filter( 'wp_prepare_attachment_for_js', [ $this, 'alter_attachment_for_js' ], 10, 3 );
    68         add_filter( 'wp_image_src_get_dimensions', [ $this, 'alter_img_tag_w_h' ], 10, 4 );
    6968        add_filter( 'get_attached_file', [ $this, 'alter_attached_file_response' ], 10, 2 );
    7069        add_filter( 'wp_calculate_image_srcset', [ $this, 'disable_dam_images_srcset' ], 1, 5 );
     
    205204        }
    206205        $image_url     = wp_get_attachment_url( $attachment_id );
    207         $incoming_size = $this->parse_dimension_from_optimized_url( $image_url );
    208         $width         = $incoming_size[0];
    209         $height        = $incoming_size[1];
     206        list($width, $height) = $this->parse_dimension_from_optimized_url( $image_url );
    210207
    211208        // Skip resize in single attachment view on backend.
     
    213210            return [
    214211                $image_url,
    215                 $width,
    216                 $height,
     212                $width === 'auto' ? false : $width,
     213                $height === 'auto' ? false : $height,
    217214                false,
    218215            ];
     
    659656
    660657    /**
    661      * We have to short-circuit the logic that adds width and height to the img tag.
    662      * It compares the URL basename, and the `file` param for each image.
    663      * This happens for any image that gets its size set non-explicitly
    664      * e.g. an image block with its size set from the sidebar to `thumbnail`).
    665      *
    666      * Optimole has a single basename for all image resizes in its URL.
    667      *
    668      * @param array|false $dimensions    Array with first element being the width
    669      *                                   and second element being the height, or
    670      *                                   false if dimensions could not be determined.
    671      * @param string      $image_src     The image URL (will be Optimole URL).
    672      * @param array       $image_meta    The image metadata.
    673      * @param int         $attachment_id The image attachment ID. Default 0.
    674      */
    675     public function alter_img_tag_w_h( $dimensions, $image_src, $image_meta, $attachment_id ) {
    676         if ( ! $this->is_dam_imported_image( $attachment_id ) ) {
    677             return $dimensions;
    678         }
    679 
    680         // Get the dimensions from the optimized URL.
    681         $incoming_size = $this->parse_dimension_from_optimized_url( $image_src );
    682         $width         = $incoming_size[0];
    683         $height        = $incoming_size[1];
    684 
    685         $sizes = Optml_App_Replacer::image_sizes();
    686 
    687         // If this is an image size. Return its dimensions.
    688         foreach ( $sizes as $size => $args ) {
    689             if ( (int) $args['width'] !== (int) $width ) {
    690                 continue;
    691             }
    692 
    693             if ( (int) $args['height'] !== (int) $height ) {
    694                 continue;
    695             }
    696 
    697             return [
    698                 $args['width'],
    699                 $args['height'],
    700             ];
    701         }
    702 
    703         // Fall-through with the original dimensions.
    704         return $dimensions;
    705     }
    706 
    707     /**
    708658     * Replace the image size params in DAM URLs inside a string.
    709659     *
  • optimole-wp/tags/4.0.1/inc/lazyload_replacer.php

    r3272237 r3276044  
    254254        // Remove fetchpriority high attribute when the image is lazyloaded
    255255        if ( strpos( $new_tag, 'fetchpriority' ) !== false ) {
    256             $new_tag = preg_replace( '/\s+fetchpriority=(high|[\'"][^\'"]*high[^\'"]*)(?=[\'"\s>]|$)/i', '', $new_tag );
     256            $new_tag = str_ireplace(
     257                [
     258                    'fetchpriority=high',
     259                    'fetchpriority="high"',
     260                    "fetchpriority='high'",
     261                    'fetchpriority=\"high\"',
     262                    "fetchpriority=\'high\'",
     263                ],
     264                '',
     265                $new_tag
     266            );
    257267        }
    258268
  • optimole-wp/tags/4.0.1/inc/media_offload.php

    r3272237 r3276044  
    24422442            $size = $this->parse_dimension_from_optimized_url( $url );
    24432443
     2444            if ( $size[0] === false || $size[1] === false ) {
     2445                continue;
     2446            }
    24442447            if ( $size[0] === 'auto' || $size[1] === 'auto' ) {
    24452448                continue;
  • optimole-wp/tags/4.0.1/inc/tag_replacer.php

    r3272237 r3276044  
    5959        add_filter( 'wp_calculate_image_srcset', [ $this, 'filter_srcset_attr' ], PHP_INT_MAX - 1, 5 );
    6060        add_filter( 'wp_calculate_image_sizes', [ $this, 'filter_sizes_attr' ], 1, 2 );
     61        add_filter( 'wp_image_src_get_dimensions', [ $this, 'filter_image_src_get_dimensions' ], 99, 4 );
    6162        if ( $this->settings->get( 'retina_images' ) === 'enabled' ) {
    6263            add_filter( 'wp_get_attachment_image_attributes', [ $this, 'filter_attachment_image_attributes' ], 99, 3 );
    6364        }
     65    }
     66
     67    /**
     68     * We have to short-circuit the logic that adds width and height to the img tag.
     69     * It compares the URL basename, and the `file` param for each image.
     70     * This happens for any image that gets its size set non-explicitly
     71     * e.g. an image block with its size set from the sidebar to `thumbnail`).
     72     *
     73     * Optimole has a single basename for all image resizes in its URL.
     74     *
     75     * @param mixed $dimensions The dimensions of the image.
     76     * @param mixed $image_src The source of the image.
     77     * @param mixed $image_meta The meta of the image.
     78     * @param mixed $attachment_id The ID of the attachment.
     79     */
     80    public function filter_image_src_get_dimensions( $dimensions, $image_src, $image_meta, $attachment_id ) {
     81
     82        list($width, $height) = $this->parse_dimension_from_optimized_url( $image_src );
     83
     84        if ( false === $width || false === $height ) {
     85            return $dimensions;
     86        }
     87        $sizes = Optml_App_Replacer::image_sizes();
     88
     89        // If this is an image size. Return its dimensions.
     90        foreach ( $sizes as $size => $args ) {
     91            if ( (int) $args['width'] !== (int) $width ) {
     92                continue;
     93            }
     94
     95            if ( (int) $args['height'] !== (int) $height ) {
     96                continue;
     97            }
     98
     99            return [
     100                $args['width'],
     101                $args['height'],
     102            ];
     103        }
     104
     105        // Fall-through with the original dimensions.
     106        return $dimensions;
    64107    }
    65108    /**
     
    512555
    513556        $image_meta = wp_get_attachment_metadata( $attachment_id );
    514         $sizes = $this->size_to_dimension( $size, $image_meta );
     557        $sizes = $this->size_to_dimension( $size, $image_meta, $attachment_id );
     558
    515559        $image_url = $this->strip_image_size_from_url( $image_url );
    516560
  • optimole-wp/tags/4.0.1/inc/traits/dam_offload_utils.php

    r3185495 r3276044  
    9292    private function parse_dimension_from_optimized_url( $url ) {
    9393        $catch  = [];
    94         $height = 'auto';
    95         $width  = 'auto';
     94        $height = false;
     95        $width  = false;
    9696        preg_match( '/\/w:(.*)\/h:(.*)\/q:/', $url, $catch );
    9797        if ( isset( $catch[1] ) && isset( $catch[2] ) ) {
  • optimole-wp/tags/4.0.1/inc/traits/normalizer.php

    r3272237 r3276044  
    196196     * @param mixed $size The size of the image. Can be an array of width and height, a predefined size, or 'full'.
    197197     * @param array $image_meta Metadata of the image, including width and height.
     198     * @param int   $attachment_id The ID of the attachment.
    198199     *
    199200     * @return array The dimensions of the image, including width, height, and optional resize parameters.
    200201     */
    201     public function size_to_dimension( $size, $image_meta ) {
     202    public function size_to_dimension( $size, $image_meta, $attachment_id = null ) {
    202203        // default size
    203204        $sizes = [
     
    206207        ];
    207208        $image_args = Optml_App_Replacer::image_sizes();
     209        $sizes2crop = Optml_App_Replacer::size_to_crop();
    208210        switch ( $size ) {
    209211            case is_array( $size ):
     
    217219                    return self::$dimension_cache[ $cache_key ];
    218220                }
    219                 $image_resized = image_resize_dimensions( $sizes['width'], $sizes['height'], $width, $height );
    220                 if ( $image_resized ) {
    221                     $width  = $image_resized[6];
    222                     $height = $image_resized[7];
    223                 } else {
    224                     $width  = $image_meta['width'];
    225                     $height = $image_meta['height'];
    226                 }
    227                 list( $sizes['width'], $sizes['height'] ) = image_constrain_size_for_editor( $width, $height, $size );
    228 
     221                if ( $attachment_id ) {
     222                    $intermediate = image_get_intermediate_size( $attachment_id, $size );
     223                    if ( $intermediate ) {
     224                        $sizes['width'] = $intermediate['width'];
     225                        $sizes['height'] = $intermediate['height'];
     226                    }
     227                }
     228
     229                list( $sizes['width'], $sizes['height'] ) = image_constrain_size_for_editor( $sizes['width'], $sizes['height'], $size );
     230                $resize = apply_filters( 'optml_default_crop', [] );
     231                if ( isset( $sizes2crop[ $sizes['width'] . $sizes['height'] ] ) ) {
     232                    $resize = $this->to_optml_crop( $sizes2crop[ $sizes['width'] . $sizes['height'] ] );
     233                }
     234                $sizes['resize'] = $resize;
    229235                self::$dimension_cache[ $cache_key ] = $sizes;
    230236                break;
  • optimole-wp/tags/4.0.1/optimole-wp.php

    r3272237 r3276044  
    33 * Plugin Name:       Image optimization service by Optimole
    44 * Description:       Complete handling of your website images.
    5  * Version:           4.0.0
     5 * Version:           4.0.1
    66 * Author:            Optimole
    77 * Author URI:        https://optimole.com
     
    9090    define( 'OPTML_URL', plugin_dir_url( __FILE__ ) );
    9191    define( 'OPTML_PATH', plugin_dir_path( __FILE__ ) );
    92     define( 'OPTML_VERSION', '4.0.0' );
     92    define( 'OPTML_VERSION', '4.0.1' );
    9393    define( 'OPTML_NAMESPACE', 'optml' );
    9494    define( 'OPTML_BASEFILE', __FILE__ );
  • optimole-wp/tags/4.0.1/readme.txt

    r3274492 r3276044  
    55Tested up to: 6.8
    66Requires PHP: 7.4
    7 Stable tag: 4.0.0
     7Stable tag: 4.0.1
    88License: GPLv3
    99License URI: https://www.gnu.org/licenses/gpl-3.0.en.html
     
    248248== Changelog ==
    249249
    250 #### [Version 4.0.0](https://github.com/Codeinwp/optimole-wp/compare/v3.14.1...v4.0.0) (2025-04-14)
    251 
    252 ### New Features
    253 
    254 - Added [client-side detection](https://docs.optimole.com/article/1948-bypass-lazy-load-for-first-images) of above-the-fold images with device-specific lazy loading for improved performance on both desktop and mobile.
    255 - Introduced [video](https://docs.optimole.com/article/2254-how-to-use-optimole-video-integration) integration that allows uploading, managing, and displaying videos directly via the Optimole DAM.
    256 - Enabled rename and replace functionality for media files within both the WordPress media library and the Optimole Cloud Library.
    257 - Simplified compression settings with [presets](https://docs.optimole.com/article/2252-choose-the-best-optimization-preset-for-your-website) for Speed and Quality optimized workflows.
    258 - Added a download button in the Optimole Cloud Library for quick image retrieval.
    259 - Introduced a WordPress dashboard widget showing visits, optimizations, and latest media activity.
    260 - Launched a [referral](https://docs.optimole.com/article/2253-referral-program) program where each referral grants 500 extra visits, up to 5,000.
    261 - Added support to host and serve PDFs from the Optimole.
    262 - Added support for JPEG XL format
    263 
    264 ---
    265 
    266 ### Enhancements
    267 
    268 - Added direct access to the Optimole Cloud Library from the plugin settings for faster navigation.
    269 - Redesigned the plugin dashboard layout to make metrics clearer and easier to read.
    270 - Enhanced Optimole badge settings with position options and icon-only display mode.
    271 - Added sorting options in the Cloud Library to organize media by upload time or file size.
    272 - Refreshed the first plugin screen with improved trust-building elements.
    273 - Enhanced image preloading logic to more accurately detect and prioritize visible images.
    274 - Displayed clear warnings when free users are approaching their offload limits.
    275 - Added slider navigation and persistent folder state to the Cloud Library for a better media browsing experience.
    276 - Displayed offload quota usage directly in the plugin dashboard.
    277 
    278 ---
    279 
    280 ### Bug Fixes
    281 
    282 - Fixed pixelated SVGs by ensuring proper format is served.
    283 - Prevented redirect issues when rolling back offloaded images in the media library.
    284 - Respected custom image dimensions set in Elementor sliders during auto-scaling.
    285 - Stopped misidentification of mega menu images as hero images.
    286 - Prevented broken links when editing cloud-only images by redirecting to the Optimole Library.
    287 - Preserved original image URLs in Gutenberg when lazy load and scaling are disabled.
    288 - Fixed issue where product gallery images from the Cloud Library also appeared in product descriptions.
    289 - Resolved incorrect quota display for disabled accounts with badge enabled.
    290 - Ensured first-time DAM authorization works across all browsers.
    291 - Corrected sorting so newest uploads appear at the top of the Cloud Library.
    292 - Cleared cache automatically when images are updated on the site.
    293 - Made update and delete buttons for watermarks visible when multiple rows exist.
    294 - Clarified that excluding an image from optimization also excludes it from lazy loading.
    295 - Stopped image distortion when no size attributes are present and scaling is disabled.
    296 - Synced folder tree view and search in the Cloud Library for consistent navigation.
     250##### [Version 4.0.1](https://github.com/Codeinwp/optimole-wp/compare/v4.0.0...v4.0.1) (2025-04-17)
     251
     252Fix extraneous quotation mark in image URL when changing fetchpriority. 
     253Fix resize behavior for certain image sizes that were improperly resized.
    297254
    298255
  • optimole-wp/trunk/CHANGELOG.md

    r3272237 r3276044  
     1##### [Version 4.0.1](https://github.com/Codeinwp/optimole-wp/compare/v4.0.0...v4.0.1) (2025-04-17)
     2
     3Fix extraneous quotation mark in image URL when changing fetchpriority. 
     4Fix resize behavior for certain image sizes that were improperly resized.
     5
    16#### [Version 4.0.0](https://github.com/Codeinwp/optimole-wp/compare/v3.14.1...v4.0.0) (2025-04-14)
    27
  • optimole-wp/trunk/README.md

    r3272237 r3276044  
    33**Tags:** image optimization, convert webp, image optimizer, lazy load, image, optimisation, convert AVIF, resize, free cdn, compress images, optimize images 
    44**Requires at least:** 5.5 
    5 **Tested up to:** 6.7 
     5**Tested up to:** 6.8 
    66**Requires PHP:** 7.4 
    7 **Stable tag:** 4.0.0 
     7**Stable tag:** 4.0.1 
    88**License:** GPLv3 
    99**License URI:** https://www.gnu.org/licenses/gpl-3.0.en.html 
     
    248248## Changelog ##
    249249
    250 #### [Version 4.0.0](https://github.com/Codeinwp/optimole-wp/compare/v3.14.1...v4.0.0) (2025-04-14)
    251 
    252 ### New Features
    253 
    254 - Added [client-side detection](https://docs.optimole.com/article/1948-bypass-lazy-load-for-first-images) of above-the-fold images with device-specific lazy loading for improved performance on both desktop and mobile.
    255 - Introduced [video](https://docs.optimole.com/article/2254-how-to-use-optimole-video-integration) integration that allows uploading, managing, and displaying videos directly via the Optimole DAM.
    256 - Enabled rename and replace functionality for media files within both the WordPress media library and the Optimole Cloud Library.
    257 - Simplified compression settings with [presets](https://docs.optimole.com/article/2252-choose-the-best-optimization-preset-for-your-website) for Speed and Quality optimized workflows.
    258 - Added a download button in the Optimole Cloud Library for quick image retrieval.
    259 - Introduced a WordPress dashboard widget showing visits, optimizations, and latest media activity.
    260 - Launched a [referral](https://docs.optimole.com/article/2253-referral-program) program where each referral grants 500 extra visits, up to 5,000.
    261 - Added support to host and serve PDFs from the Optimole.
    262 - Added support for JPEG XL format
    263 
    264 ---
    265 
    266 ### Enhancements
    267 
    268 - Added direct access to the Optimole Cloud Library from the plugin settings for faster navigation.
    269 - Redesigned the plugin dashboard layout to make metrics clearer and easier to read.
    270 - Enhanced Optimole badge settings with position options and icon-only display mode.
    271 - Added sorting options in the Cloud Library to organize media by upload time or file size.
    272 - Refreshed the first plugin screen with improved trust-building elements.
    273 - Enhanced image preloading logic to more accurately detect and prioritize visible images.
    274 - Displayed clear warnings when free users are approaching their offload limits.
    275 - Added slider navigation and persistent folder state to the Cloud Library for a better media browsing experience.
    276 - Displayed offload quota usage directly in the plugin dashboard.
    277 
    278 ---
    279 
    280 ### Bug Fixes
    281 
    282 - Fixed pixelated SVGs by ensuring proper format is served.
    283 - Prevented redirect issues when rolling back offloaded images in the media library.
    284 - Respected custom image dimensions set in Elementor sliders during auto-scaling.
    285 - Stopped misidentification of mega menu images as hero images.
    286 - Prevented broken links when editing cloud-only images by redirecting to the Optimole Library.
    287 - Preserved original image URLs in Gutenberg when lazy load and scaling are disabled.
    288 - Fixed issue where product gallery images from the Cloud Library also appeared in product descriptions.
    289 - Resolved incorrect quota display for disabled accounts with badge enabled.
    290 - Ensured first-time DAM authorization works across all browsers.
    291 - Corrected sorting so newest uploads appear at the top of the Cloud Library.
    292 - Cleared cache automatically when images are updated on the site.
    293 - Made update and delete buttons for watermarks visible when multiple rows exist.
    294 - Clarified that excluding an image from optimization also excludes it from lazy loading.
    295 - Stopped image distortion when no size attributes are present and scaling is disabled.
    296 - Synced folder tree view and search in the Cloud Library for consistent navigation.
     250##### [Version 4.0.1](https://github.com/Codeinwp/optimole-wp/compare/v4.0.0...v4.0.1) (2025-04-17)
     251
     252Fix extraneous quotation mark in image URL when changing fetchpriority. 
     253Fix resize behavior for certain image sizes that were improperly resized.
    297254
    298255
  • optimole-wp/trunk/inc/app_replacer.php

    r3272237 r3276044  
    222222     * @return array Size mapping.
    223223     */
    224     protected static function size_to_crop() {
     224    public static function size_to_crop() {
    225225        if ( ! empty( self::$size_to_crop ) ) {
    226226            return self::$size_to_crop;
     
    615615        } else {
    616616            $optimized_args = $this->parse_dimension_from_optimized_url( $src );
    617             if ( $optimized_args[0] !== 'auto' || $optimized_args[1] !== 'auto' ) {
     617            if ( $optimized_args[0] !== false || $optimized_args[1] !== false ) {
    618618                return [
    619619                    $optimized_args[0] !== 'auto' ? (int) $optimized_args[0] : false,
  • optimole-wp/trunk/inc/dam.php

    r3272237 r3276044  
    6666        add_filter( 'image_downsize', [ $this, 'catch_downsize' ], 10, 3 );
    6767        add_filter( 'wp_prepare_attachment_for_js', [ $this, 'alter_attachment_for_js' ], 10, 3 );
    68         add_filter( 'wp_image_src_get_dimensions', [ $this, 'alter_img_tag_w_h' ], 10, 4 );
    6968        add_filter( 'get_attached_file', [ $this, 'alter_attached_file_response' ], 10, 2 );
    7069        add_filter( 'wp_calculate_image_srcset', [ $this, 'disable_dam_images_srcset' ], 1, 5 );
     
    205204        }
    206205        $image_url     = wp_get_attachment_url( $attachment_id );
    207         $incoming_size = $this->parse_dimension_from_optimized_url( $image_url );
    208         $width         = $incoming_size[0];
    209         $height        = $incoming_size[1];
     206        list($width, $height) = $this->parse_dimension_from_optimized_url( $image_url );
    210207
    211208        // Skip resize in single attachment view on backend.
     
    213210            return [
    214211                $image_url,
    215                 $width,
    216                 $height,
     212                $width === 'auto' ? false : $width,
     213                $height === 'auto' ? false : $height,
    217214                false,
    218215            ];
     
    659656
    660657    /**
    661      * We have to short-circuit the logic that adds width and height to the img tag.
    662      * It compares the URL basename, and the `file` param for each image.
    663      * This happens for any image that gets its size set non-explicitly
    664      * e.g. an image block with its size set from the sidebar to `thumbnail`).
    665      *
    666      * Optimole has a single basename for all image resizes in its URL.
    667      *
    668      * @param array|false $dimensions    Array with first element being the width
    669      *                                   and second element being the height, or
    670      *                                   false if dimensions could not be determined.
    671      * @param string      $image_src     The image URL (will be Optimole URL).
    672      * @param array       $image_meta    The image metadata.
    673      * @param int         $attachment_id The image attachment ID. Default 0.
    674      */
    675     public function alter_img_tag_w_h( $dimensions, $image_src, $image_meta, $attachment_id ) {
    676         if ( ! $this->is_dam_imported_image( $attachment_id ) ) {
    677             return $dimensions;
    678         }
    679 
    680         // Get the dimensions from the optimized URL.
    681         $incoming_size = $this->parse_dimension_from_optimized_url( $image_src );
    682         $width         = $incoming_size[0];
    683         $height        = $incoming_size[1];
    684 
    685         $sizes = Optml_App_Replacer::image_sizes();
    686 
    687         // If this is an image size. Return its dimensions.
    688         foreach ( $sizes as $size => $args ) {
    689             if ( (int) $args['width'] !== (int) $width ) {
    690                 continue;
    691             }
    692 
    693             if ( (int) $args['height'] !== (int) $height ) {
    694                 continue;
    695             }
    696 
    697             return [
    698                 $args['width'],
    699                 $args['height'],
    700             ];
    701         }
    702 
    703         // Fall-through with the original dimensions.
    704         return $dimensions;
    705     }
    706 
    707     /**
    708658     * Replace the image size params in DAM URLs inside a string.
    709659     *
  • optimole-wp/trunk/inc/lazyload_replacer.php

    r3272237 r3276044  
    254254        // Remove fetchpriority high attribute when the image is lazyloaded
    255255        if ( strpos( $new_tag, 'fetchpriority' ) !== false ) {
    256             $new_tag = preg_replace( '/\s+fetchpriority=(high|[\'"][^\'"]*high[^\'"]*)(?=[\'"\s>]|$)/i', '', $new_tag );
     256            $new_tag = str_ireplace(
     257                [
     258                    'fetchpriority=high',
     259                    'fetchpriority="high"',
     260                    "fetchpriority='high'",
     261                    'fetchpriority=\"high\"',
     262                    "fetchpriority=\'high\'",
     263                ],
     264                '',
     265                $new_tag
     266            );
    257267        }
    258268
  • optimole-wp/trunk/inc/media_offload.php

    r3272237 r3276044  
    24422442            $size = $this->parse_dimension_from_optimized_url( $url );
    24432443
     2444            if ( $size[0] === false || $size[1] === false ) {
     2445                continue;
     2446            }
    24442447            if ( $size[0] === 'auto' || $size[1] === 'auto' ) {
    24452448                continue;
  • optimole-wp/trunk/inc/tag_replacer.php

    r3272237 r3276044  
    5959        add_filter( 'wp_calculate_image_srcset', [ $this, 'filter_srcset_attr' ], PHP_INT_MAX - 1, 5 );
    6060        add_filter( 'wp_calculate_image_sizes', [ $this, 'filter_sizes_attr' ], 1, 2 );
     61        add_filter( 'wp_image_src_get_dimensions', [ $this, 'filter_image_src_get_dimensions' ], 99, 4 );
    6162        if ( $this->settings->get( 'retina_images' ) === 'enabled' ) {
    6263            add_filter( 'wp_get_attachment_image_attributes', [ $this, 'filter_attachment_image_attributes' ], 99, 3 );
    6364        }
     65    }
     66
     67    /**
     68     * We have to short-circuit the logic that adds width and height to the img tag.
     69     * It compares the URL basename, and the `file` param for each image.
     70     * This happens for any image that gets its size set non-explicitly
     71     * e.g. an image block with its size set from the sidebar to `thumbnail`).
     72     *
     73     * Optimole has a single basename for all image resizes in its URL.
     74     *
     75     * @param mixed $dimensions The dimensions of the image.
     76     * @param mixed $image_src The source of the image.
     77     * @param mixed $image_meta The meta of the image.
     78     * @param mixed $attachment_id The ID of the attachment.
     79     */
     80    public function filter_image_src_get_dimensions( $dimensions, $image_src, $image_meta, $attachment_id ) {
     81
     82        list($width, $height) = $this->parse_dimension_from_optimized_url( $image_src );
     83
     84        if ( false === $width || false === $height ) {
     85            return $dimensions;
     86        }
     87        $sizes = Optml_App_Replacer::image_sizes();
     88
     89        // If this is an image size. Return its dimensions.
     90        foreach ( $sizes as $size => $args ) {
     91            if ( (int) $args['width'] !== (int) $width ) {
     92                continue;
     93            }
     94
     95            if ( (int) $args['height'] !== (int) $height ) {
     96                continue;
     97            }
     98
     99            return [
     100                $args['width'],
     101                $args['height'],
     102            ];
     103        }
     104
     105        // Fall-through with the original dimensions.
     106        return $dimensions;
    64107    }
    65108    /**
     
    512555
    513556        $image_meta = wp_get_attachment_metadata( $attachment_id );
    514         $sizes = $this->size_to_dimension( $size, $image_meta );
     557        $sizes = $this->size_to_dimension( $size, $image_meta, $attachment_id );
     558
    515559        $image_url = $this->strip_image_size_from_url( $image_url );
    516560
  • optimole-wp/trunk/inc/traits/dam_offload_utils.php

    r3185495 r3276044  
    9292    private function parse_dimension_from_optimized_url( $url ) {
    9393        $catch  = [];
    94         $height = 'auto';
    95         $width  = 'auto';
     94        $height = false;
     95        $width  = false;
    9696        preg_match( '/\/w:(.*)\/h:(.*)\/q:/', $url, $catch );
    9797        if ( isset( $catch[1] ) && isset( $catch[2] ) ) {
  • optimole-wp/trunk/inc/traits/normalizer.php

    r3272237 r3276044  
    196196     * @param mixed $size The size of the image. Can be an array of width and height, a predefined size, or 'full'.
    197197     * @param array $image_meta Metadata of the image, including width and height.
     198     * @param int   $attachment_id The ID of the attachment.
    198199     *
    199200     * @return array The dimensions of the image, including width, height, and optional resize parameters.
    200201     */
    201     public function size_to_dimension( $size, $image_meta ) {
     202    public function size_to_dimension( $size, $image_meta, $attachment_id = null ) {
    202203        // default size
    203204        $sizes = [
     
    206207        ];
    207208        $image_args = Optml_App_Replacer::image_sizes();
     209        $sizes2crop = Optml_App_Replacer::size_to_crop();
    208210        switch ( $size ) {
    209211            case is_array( $size ):
     
    217219                    return self::$dimension_cache[ $cache_key ];
    218220                }
    219                 $image_resized = image_resize_dimensions( $sizes['width'], $sizes['height'], $width, $height );
    220                 if ( $image_resized ) {
    221                     $width  = $image_resized[6];
    222                     $height = $image_resized[7];
    223                 } else {
    224                     $width  = $image_meta['width'];
    225                     $height = $image_meta['height'];
    226                 }
    227                 list( $sizes['width'], $sizes['height'] ) = image_constrain_size_for_editor( $width, $height, $size );
    228 
     221                if ( $attachment_id ) {
     222                    $intermediate = image_get_intermediate_size( $attachment_id, $size );
     223                    if ( $intermediate ) {
     224                        $sizes['width'] = $intermediate['width'];
     225                        $sizes['height'] = $intermediate['height'];
     226                    }
     227                }
     228
     229                list( $sizes['width'], $sizes['height'] ) = image_constrain_size_for_editor( $sizes['width'], $sizes['height'], $size );
     230                $resize = apply_filters( 'optml_default_crop', [] );
     231                if ( isset( $sizes2crop[ $sizes['width'] . $sizes['height'] ] ) ) {
     232                    $resize = $this->to_optml_crop( $sizes2crop[ $sizes['width'] . $sizes['height'] ] );
     233                }
     234                $sizes['resize'] = $resize;
    229235                self::$dimension_cache[ $cache_key ] = $sizes;
    230236                break;
  • optimole-wp/trunk/optimole-wp.php

    r3272237 r3276044  
    33 * Plugin Name:       Image optimization service by Optimole
    44 * Description:       Complete handling of your website images.
    5  * Version:           4.0.0
     5 * Version:           4.0.1
    66 * Author:            Optimole
    77 * Author URI:        https://optimole.com
     
    9090    define( 'OPTML_URL', plugin_dir_url( __FILE__ ) );
    9191    define( 'OPTML_PATH', plugin_dir_path( __FILE__ ) );
    92     define( 'OPTML_VERSION', '4.0.0' );
     92    define( 'OPTML_VERSION', '4.0.1' );
    9393    define( 'OPTML_NAMESPACE', 'optml' );
    9494    define( 'OPTML_BASEFILE', __FILE__ );
  • optimole-wp/trunk/readme.txt

    r3274492 r3276044  
    55Tested up to: 6.8
    66Requires PHP: 7.4
    7 Stable tag: 4.0.0
     7Stable tag: 4.0.1
    88License: GPLv3
    99License URI: https://www.gnu.org/licenses/gpl-3.0.en.html
     
    248248== Changelog ==
    249249
    250 #### [Version 4.0.0](https://github.com/Codeinwp/optimole-wp/compare/v3.14.1...v4.0.0) (2025-04-14)
    251 
    252 ### New Features
    253 
    254 - Added [client-side detection](https://docs.optimole.com/article/1948-bypass-lazy-load-for-first-images) of above-the-fold images with device-specific lazy loading for improved performance on both desktop and mobile.
    255 - Introduced [video](https://docs.optimole.com/article/2254-how-to-use-optimole-video-integration) integration that allows uploading, managing, and displaying videos directly via the Optimole DAM.
    256 - Enabled rename and replace functionality for media files within both the WordPress media library and the Optimole Cloud Library.
    257 - Simplified compression settings with [presets](https://docs.optimole.com/article/2252-choose-the-best-optimization-preset-for-your-website) for Speed and Quality optimized workflows.
    258 - Added a download button in the Optimole Cloud Library for quick image retrieval.
    259 - Introduced a WordPress dashboard widget showing visits, optimizations, and latest media activity.
    260 - Launched a [referral](https://docs.optimole.com/article/2253-referral-program) program where each referral grants 500 extra visits, up to 5,000.
    261 - Added support to host and serve PDFs from the Optimole.
    262 - Added support for JPEG XL format
    263 
    264 ---
    265 
    266 ### Enhancements
    267 
    268 - Added direct access to the Optimole Cloud Library from the plugin settings for faster navigation.
    269 - Redesigned the plugin dashboard layout to make metrics clearer and easier to read.
    270 - Enhanced Optimole badge settings with position options and icon-only display mode.
    271 - Added sorting options in the Cloud Library to organize media by upload time or file size.
    272 - Refreshed the first plugin screen with improved trust-building elements.
    273 - Enhanced image preloading logic to more accurately detect and prioritize visible images.
    274 - Displayed clear warnings when free users are approaching their offload limits.
    275 - Added slider navigation and persistent folder state to the Cloud Library for a better media browsing experience.
    276 - Displayed offload quota usage directly in the plugin dashboard.
    277 
    278 ---
    279 
    280 ### Bug Fixes
    281 
    282 - Fixed pixelated SVGs by ensuring proper format is served.
    283 - Prevented redirect issues when rolling back offloaded images in the media library.
    284 - Respected custom image dimensions set in Elementor sliders during auto-scaling.
    285 - Stopped misidentification of mega menu images as hero images.
    286 - Prevented broken links when editing cloud-only images by redirecting to the Optimole Library.
    287 - Preserved original image URLs in Gutenberg when lazy load and scaling are disabled.
    288 - Fixed issue where product gallery images from the Cloud Library also appeared in product descriptions.
    289 - Resolved incorrect quota display for disabled accounts with badge enabled.
    290 - Ensured first-time DAM authorization works across all browsers.
    291 - Corrected sorting so newest uploads appear at the top of the Cloud Library.
    292 - Cleared cache automatically when images are updated on the site.
    293 - Made update and delete buttons for watermarks visible when multiple rows exist.
    294 - Clarified that excluding an image from optimization also excludes it from lazy loading.
    295 - Stopped image distortion when no size attributes are present and scaling is disabled.
    296 - Synced folder tree view and search in the Cloud Library for consistent navigation.
     250##### [Version 4.0.1](https://github.com/Codeinwp/optimole-wp/compare/v4.0.0...v4.0.1) (2025-04-17)
     251
     252Fix extraneous quotation mark in image URL when changing fetchpriority. 
     253Fix resize behavior for certain image sizes that were improperly resized.
    297254
    298255
Note: See TracChangeset for help on using the changeset viewer.