Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

Upon further investigation, it seems that the problem is not with wp_attachment_is_image at all, but because the image size (width and height) are not being added to the attachment metadata when the SVG is uploaded. That's because the function to calculate the image used is the php function getimagesize(), which does not return an image size for SVG. I found an answer on stackoverflow about the getimagesize function and about how svgs behave. See it here.See it here.

Upon further investigation, it seems that the problem is not with wp_attachment_is_image at all, but because the image size (width and height) are not being added to the attachment metadata when the SVG is uploaded. That's because the function to calculate the image used is the php function getimagesize(), which does not return an image size for SVG. I found an answer on stackoverflow about the getimagesize function and about how svgs behave. See it here.

Upon further investigation, it seems that the problem is not with wp_attachment_is_image at all, but because the image size (width and height) are not being added to the attachment metadata when the SVG is uploaded. That's because the function to calculate the image used is the php function getimagesize(), which does not return an image size for SVG. I found an answer on stackoverflow about the getimagesize function and about how svgs behave. See it here.

added 584 characters in body
Source Link
gdaniel
  • 3.3k
  • 5
  • 29
  • 48

UPDATE

Upon further investigation, it seems that the problem is not with wp_attachment_is_image at all, but because the image size (width and height) are not being added to the attachment metadata when the SVG is uploaded. That's because the function to calculate the image used is the php function getimagesize(), which does not return an image size for SVG. I found an answer on stackoverflow about the getimagesize function and about how svgs behave. See it here.

UPDATE

Upon further investigation, it seems that the problem is not with wp_attachment_is_image at all, but because the image size (width and height) are not being added to the attachment metadata when the SVG is uploaded. That's because the function to calculate the image used is the php function getimagesize(), which does not return an image size for SVG. I found an answer on stackoverflow about the getimagesize function and about how svgs behave. See it here.

added 390 characters in body
Source Link
gdaniel
  • 3.3k
  • 5
  • 29
  • 48

I am not sure why the last if statement returns false for svgs though. Even if I don't add the svg extension to the array $image_exts, the first condition should return true, shouldn't it?

if ( 'image/' == substr($post->post_mime_type, 0, 6)

That checks if 'image/' is enqual to the first six character in the mime type, which for svg is image/svg+xml (first six is "image/").

I am not sure why the last if statement returns false for svgs though. Even if I don't add the svg extension to the array $image_exts, the first condition should return true, shouldn't it?

if ( 'image/' == substr($post->post_mime_type, 0, 6)

That checks if 'image/' is enqual to the first six character in the mime type, which for svg is image/svg+xml (first six is "image/").

added 1145 characters in body
Source Link
gdaniel
  • 3.3k
  • 5
  • 29
  • 48
Loading
added 586 characters in body
Source Link
gdaniel
  • 3.3k
  • 5
  • 29
  • 48
Loading
Tweeted twitter.com/#!/StackWordPress/status/499002886584811520
Source Link
gdaniel
  • 3.3k
  • 5
  • 29
  • 48
Loading