@@ 239-243 (lines=5) @@ | ||
236 | public function replace_images_in_content( $content ) { |
|
237 | // Added null to apply filters wp_get_attachment_url to improve compatibility with https://en-gb.wordpress.org/plugins/amazon-s3-and-cloudfront/ - does not break wordpress if the plugin isn't present. |
|
238 | if ( ! empty ( $this->options['cdn_link'] ) ) { |
|
239 | if ( preg_match_all( '/<img\s[^>]*src=([\"\']??)([^\" >]*?)\1[^>]*>/iU', $content, $matches ) ) { |
|
240 | foreach ( $matches[2] as $image_src ) { |
|
241 | $content = str_replace( $image_src, apply_filters( 'wp_get_attachment_url', $image_src, null ), $content ); |
|
242 | } |
|
243 | } |
|
244 | ||
245 | if ( preg_match_all( '/<img\s[^>]*srcset=([\"\']??)([^\">]*?)\1[^>]*\/?>/iU', $content, $matches ) ) { |
|
246 | ||
@@ 256-260 (lines=5) @@ | ||
253 | } |
|
254 | } |
|
255 | ||
256 | if ( preg_match_all( '/<a\s[^>]*href=([\"\']??)([^\" >]*?)\1[^>]*>(.*)<\/a>/iU', $content, $matches ) ) { |
|
257 | foreach ( $matches[0] as $link ) { |
|
258 | $content = str_replace( $link[2], apply_filters( 'wp_get_attachment_url', $link[2], null ), $content ); |
|
259 | } |
|
260 | } |
|
261 | ||
262 | if ( preg_match_all('/url\(([\s])?([\"|\'])?(.*?)([\"|\'])?([\s])?\)/i', $content, $matches ) ) { |
|
263 | foreach ( $matches[3] as $image_src ) { |
|
@@ 262-266 (lines=5) @@ | ||
259 | } |
|
260 | } |
|
261 | ||
262 | if ( preg_match_all('/url\(([\s])?([\"|\'])?(.*?)([\"|\'])?([\s])?\)/i', $content, $matches ) ) { |
|
263 | foreach ( $matches[3] as $image_src ) { |
|
264 | $content = str_replace( $image_src, apply_filters( 'wp_get_attachment_url', $image_src, null ), $content ); |
|
265 | } |
|
266 | } |
|
267 | } |
|
268 | return $content; |
|
269 | } |