Skip to content

Optimize: webp_uploads_upload_image_mime_transforms filter #361

@mukeshpanchal27

Description

@mukeshpanchal27

Bug Description

As we have provided filter webp_uploads_upload_image_mime_transforms for the mime type transforms in any case user does not want to transform the mime type then they just return empty, true/false or array() then this file helper.php code is not require because $transforms = (array) apply_filters( 'webp_uploads_upload_image_mime_transforms', $default_transforms ); filter always retunt array value.

Return type empty

add_filter('webp_uploads_upload_image_mime_transforms', function () {
	return;
});

Return type true/false

add_filter('webp_uploads_upload_image_mime_transforms', function () {
	return false;
});

Return type empty array:

add_filter('webp_uploads_upload_image_mime_transforms', function () {
	return array();
});

Also, we have to check if an array is null and then return an empty array so it can't execute next foreach code.

Additional Context

  • PHP Version: 8.0.15
  • OS: Windows
  • Browser: Chrome
  • Plugin Version: 1.1.0

Metadata

Metadata

Assignees

Labels

Needs DevAnything that requires development (e.g. a pull request)[Plugin] Modern Image FormatsIssues for the Modern Image Formats plugin (formerly WebP Uploads)[Type] BugAn existing feature is broken

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions