Fix: CSV import fails to download images from extension-less CDN URLs (e.g. logo.dev)#2809
Merged
Armanul46 merged 3 commits intosovware:developmentfrom Apr 15, 2026
Merged
Conversation
Member
|
Looks good |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Type
What kind of change does this PR introduce?
Description
How to reproduce the issue or how to test the changes
Problem
When importing listings via CSV with image URLs that do not have a recognisable file extension — such as logo.dev URLs like:
https://img.logo.dev/blackriflecoffee.com?token=pk_xxx
The images were silently skipped and listings showed "No Images" after import.
Root Cause
directorist_rest_upload_image_from_url() extracted the filename from the URL path before the query string, producing blackriflecoffee.com. The original guard only checked for the presence of a dot:
if ( strrpos( $file_array['name'], '.' ) === false ) {
The .com in blackriflecoffee.com satisfied this check, so no MIME detection ran. wp_handle_sideload then received a file with a .com extension, which WordPress rejects as an invalid type, causing the attachment to fail silently.
Fix
Instead of checking for any dot, the fix validates that the detected extension actually maps to an entry in WordPress's allowed MIME types. If it does not — whether because the extension is a TLD (.com, .io, .net) or is absent entirely — the file's real MIME type is read from its contents, the invalid suffix is stripped, and the correct image extension (.jpg, .png, etc.) is appended before sideloading.
Impact
Normal image URLs with valid extensions (.jpg, .png, .webp) — no behavioral change
Extension-less URLs — same behavior as before
Domain-like suffix URLs from CDNs like logo.dev — now correctly downloaded and saved to media library
REST API image uploads (categories, locations, users) — no behavioral change
Any linked issues
Fixes #
Checklist