Plugin Directory

Changeset 3240146


Ignore:
Timestamp:
02/13/2025 01:45:45 PM (11 months ago)
Author:
jonoaldersonwp
Message:
  • Fighting with Bricks
Location:
edge-images
Files:
66 added
4 edited

Legend:

Unmodified
Added
Removed
  • edge-images/trunk/classes/class-handler.php

    r3240034 r3240146  
    487487        }
    488488
    489         // Check if this is an SVG
    490         if (Helpers::is_svg($src)) {
    491             /**
    492              * Filter whether to enforce dimensions for SVG images.
    493              *
    494              * @since 5.2.14
    495              *
    496              * @param bool   $enforce_dimensions Whether to enforce dimensions.
    497              * @param string $image_html         The image HTML.
    498              * @param string $context           The context.
    499              */
    500             $enforce_dimensions = apply_filters('edge_images_enforce_svg_dimensions', true, $image_html, $context);
    501            
    502             if ($enforce_dimensions) {
    503                 $dimensions = Image_Dimensions::get($processor, $attachment_id);
    504                 if ($dimensions) {
    505                     $processor->set_attribute('width', $dimensions['width']);
    506                     $processor->set_attribute('height', $dimensions['height']);
    507                     $processor->set_attribute('class', trim($processor->get_attribute('class') . ' edge-images-processed'));
    508                     return $processor->get_updated_html();
    509                 }
    510             }
     489        // Skip if it's a non-transformable format
     490        if (Helpers::is_non_transformable_format($src)) {
    511491            return $image_html;
    512492        }
  • edge-images/trunk/classes/class-helpers.php

    r3240119 r3240146  
    135135    public static function edge_src(string $src, array $args): string {
    136136       
    137         // Skip non-transformable formats
     137        // Skip non-transformable formats (empty URLs, data: URLs, SVG, AVIF)
    138138        if (self::is_non_transformable_format($src)) {
    139139            return $src;
     
    261261     * Determines if an image format should not be transformed.
    262262     *
    263      * Checks if the image is in a format that should never be transformed,
    264      * such as SVG or AVIF, as these are already optimized formats.
    265      *
    266      * @since 5.3.0
    267      *
    268      * @param string $src The image src value.
     263        * Checks if the image URL is:
     264        * - Empty
     265        * - A data: URL
     266        * - An SVG file
     267        * - An AVIF file
     268        * - Not a string
     269        * - Doesn't begin with 'http' or '//'
     270        *
     271        * These formats should never be transformed as they are either
     272        * already optimized or cannot/should not be processed.
     273        *
     274        * @since 5.3.0
     275        *
     276        * @param string|null $src The image src value.
    269277     * @return bool Whether the image format should not be transformed.
    270278     */
    271     public static function is_non_transformable_format( string $src ): bool {
    272         return self::is_svg($src) || self::is_avif($src);
     279    public static function is_non_transformable_format( ?string $src ): bool {
     280       
     281        // Skip empty URLs
     282        if (empty($src)) {
     283            return true;
     284        }
     285
     286        // Skip data URLs
     287        if (strpos($src, 'data:') === 0) {
     288            return true;
     289        }
     290
     291        // Skip if the $src isn't a string.
     292        if (!is_string($src)) {
     293            return true;
     294        }
     295
     296        // Skip if the $src doesn't begin with 'http' or '//'
     297        if (strpos($src, 'http') !== 0 && strpos($src, '//') !== 0) {
     298            return true;
     299        }
     300
     301        // Skip if it's an SVG or AVIF file
     302        if (self::is_svg($src) || self::is_avif($src)) {
     303            return true;
     304        }
     305
     306        // If we've made it this far, the URL is transformable
     307        return false;
    273308    }
    274309
  • edge-images/trunk/edge-images.php

    r3240119 r3240146  
    88 * @link      https://github.com/jonoalderson/edge-images/
    99 * @since     1.0.0
    10  * @version   5.3.2
     10 * @version   5.3.3
    1111 *
    1212 * @wordpress-plugin
     
    1414 * Plugin URI:        https://github.com/jonoalderson/edge-images/
    1515 * Description:       Routes images through edge providers (like Cloudflare or Accelerated Domains) for automatic optimization and transformation. Improves page speed and image loading performance.
    16  * Version:           5.3.2
     16 * Version:           5.3.3
    1717 * Requires PHP:      7.4
    1818 * Requires at least: 5.6
     
    3434
    3535// Define plugin constants.
    36 define( 'EDGE_IMAGES_VERSION', '5.3.2' );
     36define( 'EDGE_IMAGES_VERSION', '5.3.3' );
    3737define( 'EDGE_IMAGES_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
    3838define( 'EDGE_IMAGES_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
  • edge-images/trunk/readme.txt

    r3240119 r3240146  
    44Tested up to: 6.7
    55Requires PHP: 7.4
    6 Stable tag: 5.3.2
     6Stable tag: 5.3.3
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    253253== Changelog ==
    254254
    255 = 5.3.2 ( 13/02/2025 ) =
     255= 5.3.3 ( 13/02/2025 ) =
    256256* BUGFIX: Tweaked the Bricks integration to improve SVG handling.
    257257
Note: See TracChangeset for help on using the changeset viewer.