8

Some images that are uploaded to WordPress don't show up in the Media Library. The images get uploaded and even cropped to the defined sizes, there is an entry in the Media Library, but the preview image doesn't show. I can even use them as a featured image and they show up correctly on my website.

I was able to find the cause of the problem: If there are special characters (like German umlauts) in the IPTC "Keywords" field in the JPGs, then this problem occurs. As soon as I use Exiftool to remove the "Keywords" field from a JPG that shows the mentioned problems, this file works without any problems. I could verify this problem on three WordPress installations on two completely different web servers hosted by different companies. The Wordpress version is 4.4.1.

I'm inclined to report this as a WordPress bug. But before doing so, I want to nail down the real problem any further. I could find that for all "bad" images, there's no _wp_attachment_metadata entry in the wp_postmeta table.

If I hack the wp-admin/includes/image.php file and set $meta['keywords'] = array(); in wp_read_image_metadata(), everything works fine. Obviously there is somewhere some code that uses the result from wp_read_image_metadata() to create a _wp_attachment_metadata row for that attachment. But where is that code that fails to insert _wp_attachment_metadata if there's a problem with wrongly encoded strings in $meta['keywords']?

And is there a hook to override that problem in my installations? One WordPress installation that shows that problem is used by several editors who are extremely computer unsavvy. Telling them to use a software on their PC to remove the faulty IPTC tags is a no-go. But I also don't want to hack the mentioned core file on a live system.

Update: Here are two identical images where one shows the problem, the other does not. The only difference is in the field "keywords", where one has the content "sweet", the other one "süß" (= German word for sweet).

image that does not work working image

5
  • As I remember, there's no standard encoding for IPTC fields, in fact it can be anything, which is pretty a mess. However +1 for the question. Can you provide a sample image to verify this behavior?
    – David
    Jan 20, 2016 at 16:21
  • 2
    Seems like a WordPress bug to me. I think you're safe to report it as-is. Feb 22, 2016 at 21:56
  • I think that this might be fixed in WordPress 4.4.2: core.trac.wordpress.org/ticket/35316
    – J.D.
    Mar 16, 2016 at 21:56
  • 2
    @z80crew Are you able to replicate this being fixed as of above comment? If so pls feel free to add an answer and mark as accepted :)
    – Tim Malone
    Jun 27, 2016 at 22:21
  • Did the core bug fix solve this? As @TimMalone says, adding and accepting an answer would help us keep WPSE tidy. Thanks. Aug 4, 2016 at 16:15

2 Answers 2

2

I have tested this with an image I created myself with Photoshop where I inserted the word "Süss" in every thinkable IPTC field.

I uploaded it to my WordPress 4.6 installation, which has no image handling plugins installed. The uploading went smoothly, the right thumbnails were created in the uploads directory and the caption field was loaded correctly from the corresponding IPTC field.

Also, the thumbnail was displayed correctly in the media library.

So, I am inclined to say that this was indeed a bug that has been solved since.

0

The problem seems to be occuring with special characters ("â", in my case) in filenames too. It happened to me at least and I never edited exif information so it ain't only related to IPTC field. It now works as expected after editing filename, removing the accent.

The weirdest is, knowing the encoding issues are often encountered, I can find no post or doc saying special characters are not acceptable or should be avoided in wordpress library filenames though, seeing the many problems people have, it would be adviseable never to use any...or ask wordpress to work on that. Maybe at least just fail uploads if any spechar is found to enforce clean names and no risk for further issue.

Hope this helps someone. Characters encoding have always been such a mess in computer science...sigh...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.