-
Notifications
You must be signed in to change notification settings - Fork 0
/
media.php
44 lines (37 loc) · 1.04 KB
/
media.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
/**
* Media functions.
*
* @package WPX
*
* @since 1.0.0
*/
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! function_exists( 'wpx_remove_image_dimensions' ) ) {
/**
* Removes the height and width attributes from inserted images.
*
* @since 1.0.0
*
* @param string $html The image HTML string.
*
* @return string The resulting HTML.
*/
function wpx_remove_image_dimensions( $html ) {
return preg_replace( '/(width|height)="\d*"\s/', '', $html );
}
} // wpx_remove_image_dimensions
if ( ! function_exists( 'wpx_register_remove_image_dimensions' ) ) {
/**
* Register remove the height and width attributes from inserted images.
*
* @since 1.0.0
*/
function wpx_register_remove_image_dimensions() {
add_filter( 'post_thumbnail_html', 'wpx_remove_image_dimensions', 10 );
add_filter( 'image_send_to_editor', 'wpx_remove_image_dimensions', 10 );
}
} // wpx_register_remove_image_dimensions