Automattic / Automattic/newspack-migration-tools

Download function during sideload will always add double extension: .jpg.jpg

Open
#138 3 comments 0 reactions 1 assignee Claimed by @jorostoyanov View on GitHub
[Status] Pending Review
Dominant language
PHP
Stars
20
Forks
5
PR merge metrics
No merged PRs in 30d

Description

If `$desired_filename` is not set, then imported image will have duplicated extension: `.jpg.jpg`, `.png.png`, etc.

Related commits:

* https://github.com/Automattic/newspack-migration-tools/pull/115/commits/1fe05faee754d70a70d4ddb68084dc7dd2c83ec0 (check was added)
* https://github.com/Automattic/newspack-migration-tools/pull/115/commits/6c92a2b09b50570e20638d201f6630516f2ef488 (desired filename passed to function)

The new check always be false: `array_search( pathinfo( $path, PATHINFO_EXTENSION ), wp_get_mime_types() )`.

Based on how `wp_get_mime_types` array is structured, the check should probably be one of the following:

* Array key exists: `array_key_exists( pathinfo( $path, PATHINFO_EXTENSION ), wp_get_mime_types() )` - but this doesn't match on `jpg|jpeg|jpe`.

* Mime match: `array_search( mime_content_type( $tmpfname ), wp_get_mime_types() )`

I'm not quite sure why that check is there...maybe to make sure the file extension matches the mime and if not, add the correct extension?

For now, setting a `$desired_filename` before calling the import will bypass the check.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.