Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. // Allow SVG without plugin
  2. add_filter( 'wp_check_filetype_and_ext', function($data, $file, $filename, $mimes) {
  3.  
  4. global $wp_version;
  5. if ( $wp_version !== '4.7.1' ) {
  6. return $data;
  7. }
  8.  
  9. $filetype = wp_check_filetype( $filename, $mimes );
  10.  
  11. return [
  12. 'ext' => $filetype['ext'],
  13. 'type' => $filetype['type'],
  14. 'proper_filename' => $data['proper_filename']
  15. ];
  16.  
  17. }, 10, 4 );
  18.  
  19. if ( ! function_exists( 'ns_cc_mime_types' ) ) {
  20. function jc_cc_mime_types( $mimes ){
  21. $mimes['svg'] = 'image/svg+xml';
  22. return $mimes;
  23. }
  24. add_filter( 'upload_mimes', 'ns_cc_mime_types' );
  25. }
  26.  
  27. if ( ! function_exists( 'ns_fix_svg' ) ) {
  28. function ns_fix_svg() {
  29. echo '<style type="text/css">
  30. .attachment-266x266, .thumbnail img {
  31. width: 100% !important;
  32. height: auto !important;
  33. }
  34. </style>';
  35. }
  36. add_action( 'admin_head', 'jc_fix_svg' );
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement