Make WordPress Core


Ignore:
Timestamp:
04/12/2022 05:16:46 AM (3 years ago)
Author:
peterwilsoncc
Message:

Media: Run the wp_content_img_tag filter once per image.

Prevent multiple identical img tags in a block of content causing the wp_content_img_tag filter to fire multiple times for that image.

Follow up to [53028].

Props superpoincare, flixos90, pbearne, peterwilsoncc.
Fixes #55510.
See #55347.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/media.php

    r53028 r53149  
    18581858                $content = str_replace( $match[0], $filtered_image, $content );
    18591859            }
     1860
     1861            /*
     1862             * Unset image lookup to not run the same logic again unnecessarily if the same image tag is used more than
     1863             * once in the same blob of content.
     1864             */
     1865            unset( $images[ $match[0] ] );
    18601866        }
    18611867
     
    18721878                $content = str_replace( $match[0], $filtered_iframe, $content );
    18731879            }
     1880
     1881            /*
     1882             * Unset iframe lookup to not run the same logic again unnecessarily if the same iframe tag is used more
     1883             * than once in the same blob of content.
     1884             */
     1885            unset( $iframes[ $match[0] ] );
    18741886        }
    18751887    }
Note: See TracChangeset for help on using the changeset viewer.