|
@@ 209-213 (lines=5) @@
|
| 206 |
|
public function replace_images_in_content( $content ) { |
| 207 |
|
// 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. |
| 208 |
|
if ( ! empty ( $this->options['cdn_link'] ) ) { |
| 209 |
|
if ( preg_match_all( '/<img\s[^>]*src=([\"\']??)([^\" >]*?)\1[^>]*>/iU', $content, $matches ) ) { |
| 210 |
|
foreach ( $matches[2] as $image_src ) { |
| 211 |
|
$content = str_replace( $image_src, apply_filters( 'wp_get_attachment_url', $image_src, null ), $content ); |
| 212 |
|
} |
| 213 |
|
} |
| 214 |
|
|
| 215 |
|
if ( preg_match_all( '/<img\s[^>]*srcset=([\"\']??)([^\">]*?)\1[^>]*\/?>/iU', $content, $matches ) ) { |
| 216 |
|
|
|
@@ 226-230 (lines=5) @@
|
| 223 |
|
} |
| 224 |
|
} |
| 225 |
|
|
| 226 |
|
if ( preg_match_all( '/<a\s[^>]*href=([\"\']??)([^\" >]*?)\1[^>]*>(.*)<\/a>/iU', $content, $matches ) ) { |
| 227 |
|
foreach ( $matches[0] as $link ) { |
| 228 |
|
$content = str_replace( $link[2], apply_filters( 'wp_get_attachment_url', $link[2], null ), $content ); |
| 229 |
|
} |
| 230 |
|
} |
| 231 |
|
} |
| 232 |
|
return $content; |
| 233 |
|
} |