This commit is contained in:
2024-05-20 15:37:46 +03:00
commit 00b7dbd0b7
10404 changed files with 3285853 additions and 0 deletions

View File

@ -0,0 +1,328 @@
<?php
/**
* Display SVG in attachment modal
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
function bodhi_svgs_response_for_svg( $response, $attachment, $meta ) {
if ( $response['mime'] == 'image/svg+xml' && empty( $response['sizes'] ) ) {
$svg_path = get_attached_file( $attachment->ID );
if ( ! file_exists( $svg_path ) ) {
// If SVG is external, use the URL instead of the path
$svg_path = $response['url'];
}
$dimensions = bodhi_svgs_get_dimensions( $svg_path );
$response['sizes'] = array(
'full' => array(
'url' => $response['url'],
'width' => $dimensions->width,
'height' => $dimensions->height,
'orientation' => $dimensions->width > $dimensions->height ? 'landscape' : 'portrait'
)
);
}
return $response;
}
add_filter( 'wp_prepare_attachment_for_js', 'bodhi_svgs_response_for_svg', 10, 3 );
function bodhi_svgs_get_dimensions( $svg ) {
$svg = simplexml_load_file( $svg );
if ( $svg === FALSE ) {
$width = '0';
$height = '0';
} else {
$attributes = $svg->attributes();
$width = (string) $attributes->width;
$height = (string) $attributes->height;
}
return (object) array( 'width' => $width, 'height' => $height );
}
/**
* Generate attachment metadata (Thanks @surml)
* Fixes Illegal String Offset Warning for Height & Width
*/
function bodhi_svgs_generate_svg_attachment_metadata( $metadata, $attachment_id ) {
$mime = get_post_mime_type( $attachment_id );
if ( $mime == 'image/svg+xml' ) {
$svg_path = get_attached_file( $attachment_id );
$upload_dir = wp_upload_dir();
// get the path relative to /uploads/ - found no better way:
$relative_path = str_replace($upload_dir['basedir'], '', $svg_path);
$filename = basename( $svg_path );
$dimensions = bodhi_svgs_get_dimensions( $svg_path );
$metadata = array(
'width' => intval($dimensions->width),
'height' => intval($dimensions->height),
'file' => $filename
);
$height = intval($dimensions->height);
$width = intval($dimensions->width);
// Might come in handy to create the sizes array too - But it's not needed for this workaround! Always links to original svg-file => Hey, it's a vector graphic! ;)
$sizes = array();
foreach ( get_intermediate_image_sizes() as $s ) {
$sizes[$s] = array( 'width' => '', 'height' => '', 'crop' => false );
// for svg with width and height set, we need to adjust the thumbnails accordingly
if ( $width !== 0 && $height !== 0 ) {
// follow width of request size e.g. 150, 300 etc..
if ( isset( $_wp_additional_image_sizes[$s]['width'] ) ) {
$width_current_size = intval( $_wp_additional_image_sizes[$s]['width'] );
} else {
$width_current_size = get_option( "{$s}_size_w" );
}
// we have dimensions available. Use them
if ( $width > $height ) {
$ratio = round($width / $height,2);
$new_height = round($width_current_size / $ratio);
} else {
$ratio = round($height / $width,2);
$new_height = round($width_current_size * $ratio);
}
$sizes[$s]['width'] = $width_current_size;
$sizes[$s]['height'] = $new_height;
// svgs can't be cropped by WP
$sizes[$s]['crop'] = false;
} else {
// no change is needed
if ( isset( $_wp_additional_image_sizes[$s]['width'] ) ) {
$sizes[$s]['width'] = intval( $_wp_additional_image_sizes[$s]['width'] ); // For theme-added sizes
} else {
$sizes[$s]['width'] = get_option( "{$s}_size_w" ); // For default sizes set in options
}
if ( isset( $_wp_additional_image_sizes[$s]['height'] ) ) {
$sizes[$s]['height'] = intval( $_wp_additional_image_sizes[$s]['height'] ); // For theme-added sizes
} else {
$sizes[$s]['height'] = get_option( "{$s}_size_h" ); // For default sizes set in options
}
if ( isset( $_wp_additional_image_sizes[$s]['crop'] ) ) {
$sizes[$s]['crop'] = intval( $_wp_additional_image_sizes[$s]['crop'] ); // For theme-added sizes
} else {
$sizes[$s]['crop'] = get_option( "{$s}_crop" ); // For default sizes set in options
}
}
$sizes[$s]['file'] = $filename;
$sizes[$s]['mime-type'] = 'image/svg+xml';
}
$metadata['sizes'] = $sizes;
}
return $metadata;
}
add_filter( 'wp_generate_attachment_metadata', 'bodhi_svgs_generate_svg_attachment_metadata', 10, 3 );
/*
* SVG Sanitization
* Only triggers when its enabled by admin
*/
function bodhi_svgs_sanitize( $file ){
global $sanitizer;
$sanitizer->setAllowedTags( new bodhi_svg_tags() );
$sanitizer->setAllowedAttrs( new bodhi_svg_attributes() );
$dirty = file_get_contents( $file );
// try to decode if gzipped is enabled
if ( $is_zipped = bodhi_svgs_is_gzipped( $dirty ) ) {
$dirty = gzdecode( $dirty );
// return on failure, since we can't read file
if ( $dirty === false ) {
return false;
}
}
// remove remote references since they are dangerous and lead to injection
$sanitizer->removeRemoteReferences(true);
// enable minify in library if its enabled in admin panel
bodhi_svgs_minify();
$clean = $sanitizer->sanitize( $dirty );
if ( $clean === false ) {
return false;
}
// if we were gzipped, we need to re-zip
if ( $is_zipped ) {
$clean = gzencode( $clean );
}
file_put_contents( $file, $clean );
return true;
}
function bodhi_svgs_minify() {
global $bodhi_svgs_options;
global $sanitizer;
if ( !empty($bodhi_svgs_options['minify_svg']) && $bodhi_svgs_options['minify_svg'] === 'on' ) {
$sanitizer->minify(true);
}
}
function bodhi_svgs_is_gzipped( $contents ) {
if ( function_exists( 'mb_strpos' ) ) {
return 0 === mb_strpos( $contents, "\x1f" . "\x8b" . "\x08" );
} else {
return 0 === strpos( $contents, "\x1f" . "\x8b" . "\x08" );
}
}
function bodhi_svgs_sanitize_svg( $file ) {
global $bodhi_svgs_options;
if ( !empty($bodhi_svgs_options['sanitize_svg']) && $bodhi_svgs_options['sanitize_svg'] === 'on' && $bodhi_svgs_options['sanitize_on_upload_roles'][0] != "none" ) {
if ( $file['type'] === 'image/svg+xml' ) {
$sanitize_on_upload_roles_array = array();
$should_sanitize_svg = array();
$sanitize_on_upload_roles_array = (array) $bodhi_svgs_options['sanitize_on_upload_roles'];
$user = wp_get_current_user();
$current_user_roles = ( array ) $user->roles;
$should_sanitize_svg = array_intersect($sanitize_on_upload_roles_array, $current_user_roles);
if( empty($should_sanitize_svg) ) {
// Do nothing Here
}
elseif ( ! bodhi_svgs_sanitize( $file['tmp_name'] ) ) {
$file['error'] = __( "Sorry, this file couldn't be sanitized for security reasons and wasn't uploaded",
'safe-svg' );
}
}
}
return $file;
}
// Sanitize svg if user has enabled option
add_filter( 'wp_handle_upload_prefilter', 'bodhi_svgs_sanitize_svg' );
// Fix image widget PHP warnings
function bodhi_svgs_get_attachment_metadata( $data ) {
$res = $data;
if ( !isset( $data['width'] ) || !isset( $data['height'] ) ) {
$res = false;
}
return $res;
}
// add_filter( 'wp_get_attachment_metadata' , 'bodhi_svgs_get_attachment_metadata' );
// Commented this out 20200307 because it was stripping metadata from other attachments as well. Need to make this target only SVG attachments.
// remove srcset for svg images
function bodhi_svgs_disable_srcset( $sources ) {
$first_element = reset($sources);
if ( isset($first_element) && !empty($first_element['url']) ) {
$ext = pathinfo(reset($sources)['url'], PATHINFO_EXTENSION);
if ( $ext == 'svg' ) {
// return empty array
$sources = array();
return $sources;
} else {
return $sources;
}
} else {
return $sources;
}
}
add_filter( 'wp_calculate_image_srcset', 'bodhi_svgs_disable_srcset' );
// fix for division by zero error for SVGs
// proposed by starsis
// https://github.com/WordPress/gutenberg/issues/36603
function bodhi_svgs_dimension_fallback( $image, $attachment_id, $size, $icon ) {
// only manipulate for svgs
if ( get_post_mime_type($attachment_id) == 'image/svg+xml' ) {
if ( isset($image[1]) && $image[1] === 0 ) {
$image[1] = 1;
}
if ( isset($image[2]) && $image[2] === 0 ) {
$image[2] = 1;
}
}
return $image;
}
add_filter( 'wp_get_attachment_image_src', 'bodhi_svgs_dimension_fallback', 10, 4 );

View File

@ -0,0 +1,58 @@
<?php
/**
* Attribute Control
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
/**
* If in Advanced Mode
*/
if ( bodhi_svgs_advanced_mode() ) {
/**
* Strip HTML of all attributes and add custom class if the file is .svg
*/
function bodhi_svgs_auto_insert_class( $html, $alt='' ) {
global $bodhi_svgs_options;
if ( ! empty( $bodhi_svgs_options['css_target'] ) ) {
// if custom class is set, use it
$class = $bodhi_svgs_options['css_target'];
} else {
// if no custom class set, use default
$class = 'style-svg';
}
// check if the src file has .svg extension
if ( strpos( $html, '.svg' ) !== FALSE ) {
// strip html for svg files
$html = preg_replace( '/(width|height|title|alt|class)=".*"\s/', 'class="' . esc_attr($class) . '"', $html );
} else {
// leave html intact for non-svg
$html = $html;
}
return $html;
}
/**
* Fire auto insert class
*/
if ( ! empty( $bodhi_svgs_options['auto_insert_class'] ) ) {
add_filter( 'image_send_to_editor', 'bodhi_svgs_auto_insert_class', 10 );
// add_filter( 'post_thumbnail_html', 'bodhi_svgs_auto_insert_class', 10 );
}
}

View File

@ -0,0 +1,224 @@
<?php
/**
* Enqueue scripts and styles
* This file is to enqueue the scripts and styles both admin and front end
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
/**
* Enqueue the admin CSS using screen check functions
*/
function bodhi_svgs_admin_css() {
// check if user is on SVG Support settings page or media library page
if ( bodhi_svgs_specific_pages_settings() || bodhi_svgs_specific_pages_media_library() ) {
// enqueue the admin CSS
wp_enqueue_style( 'bodhi-svgs-admin', BODHI_SVGS_PLUGIN_URL . 'css/svgs-admin.css' );
}
// check if user is on SVG Support settings page and not in "Advanced Mode"
if ( bodhi_svgs_specific_pages_settings() && ! bodhi_svgs_advanced_mode() ) {
// enqueue the simple mode admin CSS
wp_enqueue_style( 'bodhi-svgs-admin-simple-mode', BODHI_SVGS_PLUGIN_URL . 'css/svgs-admin-simple-mode.css' );
}
// check if user is on an edit post page
if ( bodhi_svgs_is_edit_page() ) {
// enqueue the edit post CSS
wp_enqueue_style( 'bodhi-svgs-admin-edit-post', BODHI_SVGS_PLUGIN_URL . 'css/svgs-admin-edit-post.css' );
}
}
add_action( 'admin_enqueue_scripts', 'bodhi_svgs_admin_css' );
function bodhi_svgs_admin_multiselect() {
wp_enqueue_style( 'CSS-for-multiselect', BODHI_SVGS_PLUGIN_URL . 'css/jquery.dropdown-min.css' );
wp_enqueue_script('js-for-multiselect', BODHI_SVGS_PLUGIN_URL . 'js/min/jquery.dropdown-min.js', array( 'jquery' ));
wp_enqueue_script('cstm-js-for-multiselect', BODHI_SVGS_PLUGIN_URL . 'js/min/cstm.js.multiselect-min.js', array( 'jquery' ));
wp_add_inline_script( 'js-for-multiselect', 'jQuery(document).ready(function(){jQuery(".upload_allowed_roles").dropdown({multipleMode: "label",input: \'<input type="text" maxLength="20" placeholder="Search">\',searchNoData: \'<li style="color:#ddd">No Results</li>\'});});', "after" );
wp_add_inline_script( 'js-for-multiselect', 'jQuery(document).ready(function(){jQuery(".sanitize_on_upload_roles").dropdown({multipleMode: "label",input: \'<input type="text" maxLength="20" placeholder="Search">\',searchNoData: \'<li style="color:#ddd">No Results</li>\'});});', "after" );
}
add_action( 'admin_enqueue_scripts', 'bodhi_svgs_admin_multiselect' );
/*
* Enqueue Block editor JS
*/
function bodhi_svgs_block_editor() {
if ( bodhi_svgs_advanced_mode() ) {
wp_enqueue_script('bodhi-svgs-gutenberg-filters', BODHI_SVGS_PLUGIN_URL . '/js/gutenberg-filters.js', ['wp-edit-post']);
}
}
add_action( 'enqueue_block_editor_assets', 'bodhi_svgs_block_editor' );
/**
* Enqueue front end CSS
*/
function bodhi_svgs_frontend_css() {
// get the settings
global $bodhi_svgs_options;
if ( ! empty( $bodhi_svgs_options['frontend_css'] ) ) {
// enqueue attachment CSS
wp_enqueue_style( 'bodhi-svgs-attachment', BODHI_SVGS_PLUGIN_URL . 'css/svgs-attachment.css' );
}
}
add_action( 'wp_enqueue_scripts', 'bodhi_svgs_frontend_css' );
/**
* Enqueue front end JS
*/
function bodhi_svgs_frontend_js() {
// get the settings
global $bodhi_svgs_options;
if ( !empty( $bodhi_svgs_options['sanitize_svg_front_end'] ) && $bodhi_svgs_options['sanitize_svg_front_end'] == 'on' && bodhi_svgs_advanced_mode() == true ) {
// check where the JS should be placed, header or footer
if ( ! empty( $bodhi_svgs_options['js_foot_choice'] ) ) {
$bodhi_svgs_js_footer = true;
} else {
$bodhi_svgs_js_footer = false;
}
// enqueue dompurify library js
wp_enqueue_script( 'bodhi-dompurify-library', BODHI_SVGS_PLUGIN_URL . 'vendor/DOMPurify/DOMPurify.min.js', array(), '1.0.1', $bodhi_svgs_js_footer );
}
}
add_action( 'wp_enqueue_scripts', 'bodhi_svgs_frontend_js', 9 );
/**
* Enqueue and localize JS for IMG tag replacement
*/
function bodhi_svgs_inline() {
if ( bodhi_svgs_advanced_mode() ) {
// get the settings
global $bodhi_svgs_options;
// check if force inline svg is active
if ( ! empty( $bodhi_svgs_options['force_inline_svg'] ) ) {
// set variable as true to pass to js
$force_inline_svg_active = 'true';
// set the class for use in JS
if ( ! empty( $bodhi_svgs_options['css_target'] ) ) {
// use custom class if set
$css_target_array = array(
'Bodhi' => 'img.'. esc_attr($bodhi_svgs_options['css_target']),
'ForceInlineSVG' => esc_attr($bodhi_svgs_options['css_target'])
);
} else {
// set default class
$css_target_array = array(
'Bodhi' => 'img.style-svg',
'ForceInlineSVG' => 'style-svg'
);
}
} else {
// set variable as false to pass to JS
$force_inline_svg_active = 'false';
// if custom target is set, use that, otherwise use default
if ( ! empty( $bodhi_svgs_options['css_target'] ) ) {
$css_target = 'img.'. esc_attr($bodhi_svgs_options['css_target']);
} else {
$css_target = 'img.style-svg';
}
// set the array to target for passing to JS
$css_target_array = $css_target;
}
// use expanded or minified JS
if ( ! empty( $bodhi_svgs_options['use_expanded_js'] ) ) {
// set variables to blank so we use the full JS version
$bodhi_svgs_js_folder = '';
$bodhi_svgs_js_file = '';
} else {
// set variables to the minified version in the min folder
$bodhi_svgs_js_folder = 'min/'; // min folder
$bodhi_svgs_js_file = '-min'; // min file
}
// check where the JS should be placed, header or footer
if ( ! empty( $bodhi_svgs_options['js_foot_choice'] ) ) {
$bodhi_svgs_js_footer = true;
} else {
$bodhi_svgs_js_footer = false;
}
// use vanilla js if user has enabled option in settings
if ( ! empty( $bodhi_svgs_options['use_vanilla_js'] ) ) {
$bodhi_svgs_js_vanilla = '-vanilla';
}else{
$bodhi_svgs_js_vanilla = '';
}
// create path for the correct js file
$bodhi_svgs_js_path = 'js/' . $bodhi_svgs_js_folder .'svgs-inline' . $bodhi_svgs_js_vanilla . $bodhi_svgs_js_file . '.js' ;
wp_register_script( 'bodhi_svg_inline', BODHI_SVGS_PLUGIN_URL . $bodhi_svgs_js_path, array( 'jquery' ), '1.0.1', $bodhi_svgs_js_footer );
wp_enqueue_script( 'bodhi_svg_inline' );
wp_add_inline_script(
'bodhi_svg_inline',
sprintf(
'cssTarget=%s;ForceInlineSVGActive=%s;frontSanitizationEnabled=%s;',
json_encode($css_target_array),
json_encode($force_inline_svg_active),
json_encode($bodhi_svgs_options['sanitize_svg_front_end'])
)
);
}
}
add_action( 'wp_enqueue_scripts', 'bodhi_svgs_inline' );

View File

@ -0,0 +1,122 @@
<?php
/**
* Featured image meta checkbox to inline SVG
*
* Allow users to select whether featured images should contain the SVG Support class
* Check if the featured image is SVG first, then display meta box for SVG only.
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
/**
* Add checkbox to the featured image metabox
*/
function bodhi_svgs_featured_image_meta( $content ) {
global $post;
// check if featured image is set and has extension of .svg or .svgz
// need to make this check on the moment that the thumbnail shows up in the meta box.
if ( strpos( get_the_post_thumbnail(), '.svg' ) ) {
$text = __( 'Render this SVG inline (advanced)', 'svg-support' );
$id = 'inline_featured_image';
$value = esc_attr( get_post_meta( $post->ID, $id, true ) );
$label = '<label for="' . $id . '" class="selectit"><input name="' . $id . '" type="checkbox" id="' . $id . '" value="' . $value . ' "'. checked( $value, 1, false) .'> ' . $text .'</label>';
return $content .= $label;
} else {
return $content;
}
}
if ( bodhi_svgs_advanced_mode() ) {
add_filter( 'admin_post_thumbnail_html', 'bodhi_svgs_featured_image_meta' );
}
/**
* Save featured image meta data when saved
*/
function bodhi_svgs_save_featured_image_meta( $post_id, $post, $update ) {
// if gutenberg is active, disable the classic editor checkbox
if( isset($_REQUEST['hidden_post_status']) ){
$value = 0;
if ( isset( $_REQUEST['inline_featured_image'] ) ) {
$value = 1;
}
// Check if post type supports 'thumbnail' (Featured Image)
if ( post_type_supports( get_post_type( $post_id ), 'thumbnail' ) ) {
// set meta value to either 1 or 0
update_post_meta( $post_id, 'inline_featured_image', $value );
}
}
}
add_action( 'save_post', 'bodhi_svgs_save_featured_image_meta', 10, 3 );
/*
* Save featured image meta for Gutenberg Editor
*/
function bodhi_svgs_register_meta() {
register_meta( 'post', 'inline_featured_image', array(
'show_in_rest' => true,
'single' => true,
'type' => 'boolean',
'auth_callback' => '__return_true'
) );
}
add_action( 'init', 'bodhi_svgs_register_meta' );
/**
* Add class to the featured image output on front end
*/
function bodhi_svgs_add_class_to_thumbnail( $thumb ) {
$inline_featured_image = get_post_meta( get_the_ID(), 'inline_featured_image' );
if ( is_array( $inline_featured_image ) && in_array( 1, $inline_featured_image ) ) {
global $bodhi_svgs_options;
if ( ! empty( $bodhi_svgs_options['css_target'] ) ) {
$target_class = $bodhi_svgs_options['css_target'];
} else {
$target_class = 'style-svg';
}
if ( is_singular() ) {
$thumb = str_replace( 'attachment-', $target_class . ' attachment-', $thumb );
}
}
return $thumb;
}
if ( bodhi_svgs_advanced_mode() ) {
add_filter( 'post_thumbnail_html', 'bodhi_svgs_add_class_to_thumbnail' );
}

View File

@ -0,0 +1,14 @@
<?php
/**
* INTERNATIONALIZATION / LOCALIZATION
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
add_action( 'init', 'bodhi_svgs_localization' );
function bodhi_svgs_localization() {
load_plugin_textdomain( 'svg-support', false, basename( dirname( __FILE__ ) ) . '/languages' );
}

View File

@ -0,0 +1,93 @@
<?php
/**
* Add SVG mime types to WordPress
*
* Allows you to upload SVG files to the media library like any other image.
* Additionally provides a fix for WP 4.7.1 - 4.7.2 upload issues and for Avada theme.
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
/**
* Add Mime Types
*/
function bodhi_svgs_upload_mimes( $mimes = array() ) {
global $bodhi_svgs_options;
$allowed_roles_array = array();
$is_role_allowed = array();
if( !isset($bodhi_svgs_options['restrict']) ) {
return $mimes;
}
$allowed_roles_array = (array) $bodhi_svgs_options['restrict'];
$user = wp_get_current_user();
$current_user_roles = ( array ) $user->roles;
$is_role_allowed = array_intersect($allowed_roles_array, $current_user_roles);
if( empty($is_role_allowed) ) {
return $mimes;
}
else {
// allow SVG file upload
$mimes['svg'] = 'image/svg+xml';
$mimes['svgz'] = 'image/svg+xml';
return $mimes;
}
}
add_filter( 'upload_mimes', 'bodhi_svgs_upload_mimes', 99 );
/**
* Check Mime Types
*/
function bodhi_svgs_upload_check( $checked, $file, $filename, $mimes ) {
if ( ! $checked['type'] ) {
$check_filetype = wp_check_filetype( $filename, $mimes );
$ext = $check_filetype['ext'];
$type = $check_filetype['type'];
$proper_filename = $filename;
if ( $type && 0 === strpos( $type, 'image/' ) && $ext !== 'svg' ) {
$ext = $type = false;
}
$checked = compact( 'ext','type','proper_filename' );
}
return $checked;
}
add_filter( 'wp_check_filetype_and_ext', 'bodhi_svgs_upload_check', 10, 4 );
/**
* Mime Check fix for WP 4.7.1 / 4.7.2
*
* Fixes uploads for these 2 version of WordPress.
* Issue was fixed in 4.7.3 core.
*/
function bodhi_svgs_allow_svg_upload( $data, $file, $filename, $mimes ) {
global $wp_version;
if ( $wp_version !== '4.7.1' || $wp_version !== '4.7.2' ) {
return $data;
}
$filetype = wp_check_filetype( $filename, $mimes );
return [
'ext' => $filetype['ext'],
'type' => $filetype['type'],
'proper_filename' => $data['proper_filename']
];
}
add_filter( 'wp_check_filetype_and_ext', 'bodhi_svgs_allow_svg_upload', 10, 4 );

View File

@ -0,0 +1,51 @@
<?php
/**
* ADD ABILITY TO VIEW THUMBNAILS IN WP 4.0+
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
add_action( 'admin_init', 'bodhi_svgs_display_thumbs' );
function bodhi_svgs_display_thumbs() {
if ( bodhi_svgs_specific_pages_media_library() ) {
function bodhi_svgs_thumbs_filter( $content ) {
return apply_filters( 'final_output', $content );
}
ob_start( 'bodhi_svgs_thumbs_filter' );
add_filter( 'final_output', 'bodhi_svgs_final_output' );
function bodhi_svgs_final_output( $content ) {
$content = str_replace(
'<# } else if ( \'image\' === data.type && data.sizes && data.sizes.full ) { #>',
'<# } else if ( \'svg+xml\' === data.subtype ) { #>
<img class="details-image" src="{{ data.url }}" draggable="false" />
<# } else if ( \'image\' === data.type && data.sizes && data.sizes.full ) { #>',
$content
);
$content = str_replace(
'<# } else if ( \'image\' === data.type && data.sizes ) { #>',
'<# } else if ( \'svg+xml\' === data.subtype ) { #>
<div class="centered">
<img src="{{ data.url }}" class="thumbnail" draggable="false" />
</div>
<# } else if ( \'image\' === data.type && data.sizes ) { #>',
$content
);
return $content;
}
}
}