Plugin Directory

Changeset 3446555


Ignore:
Timestamp:
01/25/2026 02:10:05 PM (3 weeks ago)
Author:
coozywana
Message:

Update to version 2.2.1 from GitHub

Location:
staticdelivr
Files:
4 edited
1 copied

Legend:

Unmodified
Added
Removed
  • staticdelivr/tags/2.2.1/README.txt

    r3446554 r3446555  
    240240== Changelog ==
    241241
     242= 2.2.1 =
     243* Fixed an issue with infinite recursion in the `rewrite_attachment_image_src` and `rewrite_attachment_url` filters.
     244* Improved handling of image URLs to prevent errors when retrieving attachment URLs.
     245
    242246= 2.2.0 =
    243247* **Fixed: Critical Bug** - Improved recovery for malformed CDN URLs by looking up original attachment paths in the database instead of guessing dates
     
    380384== Upgrade Notice ==
    381385
     386= 2.2.1 =
     387Fixes infinite recursion in image URL filters and improves handling of attachment URLs.
     388
    382389= 2.2.0 =
    383390Critical fix: Solves broken images issues by correctly recovering original file paths from the database for older content.
  • staticdelivr/tags/2.2.1/includes/class-staticdelivr-images.php

    r3446554 r3446555  
    542542
    543543        if ($attachment_id) {
     544            // Prevent infinite recursion: Temporarily remove our own filters
     545            // because wp_get_attachment_image_src triggers the 'wp_get_attachment_image_src' filter
     546            // which calls our rewrite_attachment_image_src() -> build_image_cdn_url() -> this function!
     547            remove_filter('wp_get_attachment_image_src', array($this, 'rewrite_attachment_image_src'), 10);
     548            remove_filter('wp_get_attachment_url', array($this, 'rewrite_attachment_url'), 10);
     549
     550            $original_url = false;
     551
    544552            // Check if we need a specific size.
    545553            if ($filename !== $base_filename && preg_match('/-(\d+)x(\d+)(\.[^.]+)$/', $filename, $matches)) {
     
    548556                $image_src = wp_get_attachment_image_src($attachment_id, array($width, $height));
    549557                if ($image_src && isset($image_src[0])) {
    550                     return $image_src[0];
     558                    $original_url = $image_src[0];
    551559                }
    552560            }
    553561
    554             return wp_get_attachment_url($attachment_id);
     562            if (!$original_url) {
     563                $original_url = wp_get_attachment_url($attachment_id);
     564            }
     565
     566            // Restore filters
     567            add_filter('wp_get_attachment_image_src', array($this, 'rewrite_attachment_image_src'), 10, 4);
     568            add_filter('wp_get_attachment_url', array($this, 'rewrite_attachment_url'), 10, 2);
     569
     570            return $original_url;
    555571        }
    556572
  • staticdelivr/trunk/README.txt

    r3446554 r3446555  
    240240== Changelog ==
    241241
     242= 2.2.1 =
     243* Fixed an issue with infinite recursion in the `rewrite_attachment_image_src` and `rewrite_attachment_url` filters.
     244* Improved handling of image URLs to prevent errors when retrieving attachment URLs.
     245
    242246= 2.2.0 =
    243247* **Fixed: Critical Bug** - Improved recovery for malformed CDN URLs by looking up original attachment paths in the database instead of guessing dates
     
    380384== Upgrade Notice ==
    381385
     386= 2.2.1 =
     387Fixes infinite recursion in image URL filters and improves handling of attachment URLs.
     388
    382389= 2.2.0 =
    383390Critical fix: Solves broken images issues by correctly recovering original file paths from the database for older content.
  • staticdelivr/trunk/includes/class-staticdelivr-images.php

    r3446554 r3446555  
    542542
    543543        if ($attachment_id) {
     544            // Prevent infinite recursion: Temporarily remove our own filters
     545            // because wp_get_attachment_image_src triggers the 'wp_get_attachment_image_src' filter
     546            // which calls our rewrite_attachment_image_src() -> build_image_cdn_url() -> this function!
     547            remove_filter('wp_get_attachment_image_src', array($this, 'rewrite_attachment_image_src'), 10);
     548            remove_filter('wp_get_attachment_url', array($this, 'rewrite_attachment_url'), 10);
     549
     550            $original_url = false;
     551
    544552            // Check if we need a specific size.
    545553            if ($filename !== $base_filename && preg_match('/-(\d+)x(\d+)(\.[^.]+)$/', $filename, $matches)) {
     
    548556                $image_src = wp_get_attachment_image_src($attachment_id, array($width, $height));
    549557                if ($image_src && isset($image_src[0])) {
    550                     return $image_src[0];
     558                    $original_url = $image_src[0];
    551559                }
    552560            }
    553561
    554             return wp_get_attachment_url($attachment_id);
     562            if (!$original_url) {
     563                $original_url = wp_get_attachment_url($attachment_id);
     564            }
     565
     566            // Restore filters
     567            add_filter('wp_get_attachment_image_src', array($this, 'rewrite_attachment_image_src'), 10, 4);
     568            add_filter('wp_get_attachment_url', array($this, 'rewrite_attachment_url'), 10, 2);
     569
     570            return $original_url;
    555571        }
    556572
Note: See TracChangeset for help on using the changeset viewer.