Plugin Directory

Changeset 2731665

Timestamp:
05/26/2022 10:12:08 AM (2 years ago)
Author:
ravisinghit
Message:

Updated code v5.9

File:
1 edited

Legend:

Unmodified
Added
Removed
  • asf-allow-svg-files/trunk/asfwp-allow-svg-files.php

    r2672768 r2731665  
    8383
    8484
    85 function asfwp_cc_mime_types($mimes) {
    86   define('ALLOW_UNFILTERED_UPLOADS', true);
     85// function asfwp_cc_mime_types($mimes) {
     86//   define('ALLOW_UNFILTERED_UPLOADS', true);
     87//   $mimes['svg'] = 'image/svg+xml';
     88//   $mimes['svgz'] = 'image/svg+xml';
     89//   return $mimes;
     90// }
     91// add_filter('upload_mimes', 'asfwp_cc_mime_types');
     92
     93// Allow SVG
     94add_filter( 'wp_check_filetype_and_ext', function($data, $file, $filename, $mimes) {
     95
     96  global $wp_version;
     97  if ( $wp_version !== '5.9' ) {
     98     return $data;
     99  }
     100
     101  $filetype = wp_check_filetype( $filename, $mimes );
     102
     103  return [
     104      'ext'             => $filetype['ext'],
     105      'type'            => $filetype['type'],
     106      'proper_filename' => $data['proper_filename']
     107  ];
     108
     109}, 10, 4 );
     110
     111function asfwp_cc_mime_types( $mimes ){
    87112  $mimes['svg'] = 'image/svg+xml';
    88   $mimes['svgz'] = 'image/svg+xml';
    89113  return $mimes;
    90114}
    91 add_filter('upload_mimes', 'asfwp_cc_mime_types');
     115add_filter( 'upload_mimes', 'asfwp_cc_mime_types' );
     116
     117function asfwp_fix_svg() {
     118  echo '<style type="text/css">
     119        .attachment-266x266, .thumbnail img {
     120             width: 100% !important;
     121             height: auto !important;
     122        }
     123        </style>';
     124}
     125add_action( 'admin_head', 'asfwp_fix_svg' );
Note: See TracChangeset for help on using the changeset viewer.