Sizlerle paylaşmak istedim.
Bu kodlardan hangisini kullanmam daha iyi olur?
Teşekkür ederim.
https://wpengine.com/resources/enable-svg-wordpress/
// Allow SVG
add_filter( 'wp_check_filetype_and_ext', function($data, $file, $filename, $mimes) {
global $wp_version;
if ( $wp_version !== '4.7.1' ) {
return $data;
}
$filetype = wp_check_filetype( $filename, $mimes );
return [
'ext' => $filetype['ext'],
'type' => $filetype['type'],
'proper_filename' => $data['proper_filename']
];
}, 10, 4 );
function cc_mime_types( $mimes ){
$mimes['svg'] = 'image/svg+xml';
return $mimes;
}
add_filter( 'upload_mimes', 'cc_mime_types' );
function fix_svg() {
echo '<style type="text/css">
.attachment-266x266, .thumbnail img {
width: 100% !important;
height: auto !important;
}
</style>';
}
add_action( 'admin_head', 'fix_svg' );https://neuronthemes.com/what-is-an-svg-file-and-how-to-upload-svg-in-wordpress/
// Allow SVG
add_filter( 'wp_check_filetype_and_ext', function($data, $file, $filename, $mimes) {
global $wp_version;
if ( $wp_version !== '4.7.1' ) {
return $data;
}
$filetype = wp_check_filetype( $filename, $mimes );
return [
'ext' => $filetype['ext'],
'type' => $filetype['type'],
'proper_filename' => $data['proper_filename']
];
}, 10, 4 );
function cc_mime_types( $mimes ){
$mimes['svg'] = 'image/svg+xml';
return $mimes;
}
add_filter( 'upload_mimes', 'cc_mime_types' );
function fix_svg() {
echo '';
}
add_action( 'admin_head', 'fix_svg' );https://themeisle.com/blog/add-svg-to-wordpress/
function add_file_types_to_uploads($file_types){
$new_filetypes = array();
$new_filetypes['svg'] = 'image/svg+xml';
$file_types = array_merge($file_types, $new_filetypes );
return $file_types;
}
add_filter('upload_mimes', 'add_file_types_to_uploads');https://www.designbombs.com/how-to-safely-enable-svg-support-in-wordpress-manually-via-plugin/
function enable_svg_upload( $upload_mimes ) {
$upload_mimes['svg'] = 'image/svg+xml';
$upload_mimes['svgz'] = 'image/svg+xml';
return $upload_mimes;
}
add_filter( 'upload_mimes', 'enable_svg_upload', 10, 1 );İlk 2 site konusu daha güncel. function fix_svg kısmında farklılık gösteriyor. Tam olarak kodlama konusunda uzman olmadığım için tam fark nedir bilemedim. thumbnail konusunda bir farklılık var sanırım.
son 2 konu biraz eski 2020 yılında açılmışlar kodlar ilk 2 siteye göre çok kısa ve değişik.
Şimdiden teşekkür ederim.
Kullanacak arkadaşlara da bir kaynak olmuş olur.