@@ 214-218 (lines=5) @@ | ||
211 | public function replace_images_in_content( $content ) { |
|
212 | // 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. |
|
213 | if ( ! empty ( $this->options['cdn_link'] ) ) { |
|
214 | if ( preg_match_all( '/<img\s[^>]*src=([\"\']??)([^\" >]*?)\1[^>]*>/iU', $content, $matches ) ) { |
|
215 | foreach ( $matches[2] as $image_src ) { |
|
216 | $content = str_replace( $image_src, apply_filters( 'wp_get_attachment_url', $image_src, null ), $content ); |
|
217 | } |
|
218 | } |
|
219 | ||
220 | if ( preg_match_all( '/<img\s[^>]*srcset=([\"\']??)([^\">]*?)\1[^>]*\/?>/iU', $content, $matches ) ) { |
|
221 | ||
@@ 231-235 (lines=5) @@ | ||
228 | } |
|
229 | } |
|
230 | ||
231 | if ( preg_match_all( '/<a\s[^>]*href=([\"\']??)([^\" >]*?)\1[^>]*>(.*)<\/a>/iU', $content, $matches ) ) { |
|
232 | foreach ( $matches[0] as $link ) { |
|
233 | $content = str_replace( $link[2], apply_filters( 'wp_get_attachment_url', $link[2], null ), $content ); |
|
234 | } |
|
235 | } |
|
236 | } |
|
237 | return $content; |
|
238 | } |