Plugin Directory

Changeset 3284888


Ignore:
Timestamp:
04/30/2025 12:59:36 PM (11 months ago)
Author:
emplibot
Message:

prefer gd image processing

Location:
emplibot/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • emplibot/trunk/emplibot.php

    r3284088 r3284888  
    33 * Plugin Name:       Emplibot
    44 * Description:       Automated keyword research, automated blogging, with internal and external links, engaging infographics, unique featured images, and more.
    5  * Version:           1.0.8
     5 * Version:           1.0.9
    66 * Requires at least: 6.4
    77 * Requires PHP:      7.2
  • emplibot/trunk/includes/rest-api.php

    r3284088 r3284888  
    288288        // Generate metadata for the attachment and update the database
    289289        require_once( ABSPATH . 'wp-admin/includes/image.php' );
     290       
     291        // Set preference for GD over Imagick
     292        add_filter('wp_image_editors', 'emplibot_prefer_gd_image_editor');
    290293        $attachment_data = wp_generate_attachment_metadata( $attachment_id, $image_path );
     294        // Remove the filter after processing to avoid affecting other operations
     295        remove_filter('wp_image_editors', 'emplibot_prefer_gd_image_editor');
     296       
    291297        wp_update_attachment_metadata( $attachment_id, $attachment_data );
    292298
     
    893899    // Generate metadata for the attachment
    894900    require_once(ABSPATH . 'wp-admin/includes/image.php');
     901   
     902    // Set preference for GD over Imagick
     903    add_filter('wp_image_editors', 'emplibot_prefer_gd_image_editor');
    895904    $attachment_data = wp_generate_attachment_metadata($attachment_id, $image_dest_path);
     905    // Remove the filter after processing to avoid affecting other operations
     906    remove_filter('wp_image_editors', 'emplibot_prefer_gd_image_editor');
     907   
    896908    wp_update_attachment_metadata($attachment_id, $attachment_data);
    897909   
     
    938950
    939951/**
     952 * Sets the preference for image editors to use GD first, then Imagick as fallback.
     953 *
     954 * @param array $editors Array of image editor class names.
     955 * @return array Modified array of image editor class names.
     956 */
     957function emplibot_prefer_gd_image_editor($editors) {
     958    // Define the preferred order: GD first, then Imagick
     959    $preferred_editors = array(
     960        'WP_Image_Editor_GD',
     961        'WP_Image_Editor_Imagick'
     962    );
     963   
     964    // Return our preferred order
     965    return $preferred_editors;
     966}
     967
     968/**
    940969 * Recursively removes a directory and its contents.
    941970 *
  • emplibot/trunk/readme.txt

    r3284088 r3284888  
    44Requires at least: 6.4
    55Tested up to: 6.8
    6 Stable tag: 1.0.8
     6Stable tag: 1.0.9
    77Requires PHP: 7.1
    88License: GPLv3 or later
     
    5959= 1.0.8 =
    6060* Enhanced blogpost processing.
     61
     62= 1.0.9 =
     63* Prefer GD Image processing.
Note: See TracChangeset for help on using the changeset viewer.