Skip to content

Instantly share code, notes, and snippets.

@adamsilverstein
Created September 16, 2021 19:46
Show Gist options
  • Select an option

  • Save adamsilverstein/c8b5d0145aeda7fe0a04e4573f2c7c32 to your computer and use it in GitHub Desktop.

Select an option

Save adamsilverstein/c8b5d0145aeda7fe0a04e4573f2c7c32 to your computer and use it in GitHub Desktop.
Prefer GD over Imagick when choosing the default image editor.
<?php
/**
* Prefer GD over Imagick.
*
* @wordpress-plugin
* Plugin Name: Prefer GD over Imagick.
* Description: Switches the default image editor choice order.
* Plugin URI:
* Version: 1.0.0
* Author: Adam Silverstein, Google
* License: Apache License 2.0
* License URI: https://www.apache.org/licenses/LICENSE-2.0
*/
add_filter(
'wp_image_editors',
function() {
return array( 'WP_Image_Editor_GD', 'WP_Image_Editor_Imagick' );
}
);
@scofennell
Copy link
Copy Markdown

Just wanted to mention that this snippet resolved a problem I currently have on WP Engine. They have both GD and Imagick installed, but only GD is installed with webp support.

@adamsilverstein
Copy link
Copy Markdown
Author

Thanks for confirming @scofennell!-

I'm going to look into fixing this in WordPress core where I suspect the underlying issue can be corrected. I'll ping you here when I have that fix available for testing and would appreciate confirmation that it also resolves the issue on WP Engine.

Out of curiosity, can you tell me what type of hosting plan you have with WP Engine? I'm wondering if this affects all their customers or only on certain plans.

@scofennell
Copy link
Copy Markdown

Thank you, brother!

I am experiencing this issue on a variety of plans -- but I believe they are all similar to "P3 APM Plan", or "P4", "P5", etc. I believe these are considered to be in their "custom" tier.

My support inquiry with them was elevated to a senior tech whose response indicated a lack of familiarity with the issues here ( which actually is a bit surprising considering the gymnastics they offer for webp usage via an unsavory stack of dependencies and config ( https://wpengine.com/support/webp-image-optimization/ ) ).

So I'll be happy to see you dig into this at the WP core level. Thank you for your awesome work!

@adamsilverstein
Copy link
Copy Markdown
Author

Hi @scofennell if you are able to test, I have a proposed patch for core that I think will fix this issue for you: https://github.com/WordPress/wordpress-develop/pull/1918/files

@scofennell
Copy link
Copy Markdown

scofennell commented Nov 19, 2021

Okay, very well! Thanks so much for the follow-up.

Do I need to hook into anything at all, or should I expect everything to "just work" merely by patching core in this way?

(I know that patching/hacking core is just for trying stuff as opposed to calling it a durable fix :D )

@adamsilverstein
Copy link
Copy Markdown
Author

this should now be fixed in wp core

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment