0

I've managed to modify WP so it allows .ai and .psd uploads using the following code:

add_filter('upload_mimes', 'custom_upload_mimes');

function custom_upload_mimes ( $existing_mimes = array() ) {
    $existing_mimes['psd'] = 'image/vnd.adobe.photoshop';
    $existing_mimes['ai'] = 'application/pdf';
    return $existing_mimes;
}

It's mostly working, but there's some weirdness going on in the Media Library. When uploaded, we can see the actual files and the thumbnails/attachments that WP has automatically generated.

WP Media Library Screenshot

The Illustrator file (1) is displaying fine, and you can also see its corresponding thumbnail (2). However, the Photoshop file (3) is missing the image and filename overlay, but the thumbnail is present (4).

What's also odd is that in list view, everything appears to be fine:

Media Library list view

I've been scouring through code for hours, but I still can't work it out.

5
  • 3
    You'll need to share the code you used to "modify" WP to allow these filetypes. Browsers do not have built-in ways to display them, so it's not surprising they're not just working as-is. I suspect AI is working because its format is close enough to PDF that WP knows how to parse it and autogenerate the various WP sizes such as thumbnail, medium, large and save those as JPGs or PNGs which a browser can understand. Commented Sep 6, 2024 at 13:11
  • Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Commented Sep 6, 2024 at 13:25
  • I've updated the original question with a code snippet. The script is actually creating the thumbnail and preview associated with the PSD file (see second image), so I assume that aspect of the code is working as expected. Commented Sep 6, 2024 at 13:39
  • Are those all thumbnail JPGs, i.e. it's showing you a generated thumbnail of the PSD and AI? That'll be done by either ImageMagick or GD depending on what you've got set up (you can see in Site Health Check). I'd guess one of the thumbnail sizes failed - can you see what you've got in your uploads folder? Are all the thumbnails correct and working? Commented Sep 6, 2024 at 14:09
  • Yes, it uses Imagick for ai, pdf and psd files and all the sizes are present and correct. Inspecting the DOM in the Media Library, I can see that the containing DIVs have totally different markup. The visible one contains an icon and an application class, whereas the broken one is attempting to load the psd file as the preview (but not in list view). Commented Sep 7, 2024 at 11:48

0

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.