default
2 days ago
dummy
2 days ago
shortpixel
2 days ago
class-foogallery-thumb-engine.php
2 days ago
class-foogallery-thumb-image-editor-gd.php
2 days ago
class-foogallery-thumb-image-editor-imagick.php
2 days ago
class-foogallery-thumb-manager.php
2 days ago
includes.php
2 days ago
class-foogallery-thumb-manager.php
65 lines
| 1 | <?php |
| 2 | |
| 3 | if ( ! defined( 'ABSPATH' ) ) { |
| 4 | exit; |
| 5 | } |
| 6 | |
| 7 | /** |
| 8 | * Class that managers all thumbnail generation within FooGallery |
| 9 | */ |
| 10 | if ( ! class_exists( 'FooGallery_Thumb_Manager' ) ) { |
| 11 | |
| 12 | class FooGallery_Thumb_Manager { |
| 13 | |
| 14 | function __construct() { |
| 15 | // Change from plugins_loaded to init |
| 16 | add_action( 'init', array( $this, 'init_active_engine' ) ); |
| 17 | } |
| 18 | |
| 19 | /** |
| 20 | * Make sure the active thumb engine initializes |
| 21 | */ |
| 22 | function init_active_engine() { |
| 23 | $engine = foogallery_thumb_active_engine(); |
| 24 | $engine->init(); |
| 25 | add_filter( 'wp_image_editors', array( $this, 'override_image_editors' ), 999 ); |
| 26 | } |
| 27 | |
| 28 | /** |
| 29 | * Overrides the editors to make sure the FooGallery thumb editors are included |
| 30 | * |
| 31 | * @param $editors |
| 32 | * @return array |
| 33 | */ |
| 34 | function override_image_editors( $editors ) { |
| 35 | |
| 36 | require_once( FOOGALLERY_PATH . '/includes/thumbs/class-foogallery-thumb-image-editor-gd.php' ); |
| 37 | require_once( FOOGALLERY_PATH . '/includes/thumbs/class-foogallery-thumb-image-editor-imagick.php' ); |
| 38 | |
| 39 | $image_editors = array(); |
| 40 | |
| 41 | //replace the default image editors with the FooGallery Thumb image editors |
| 42 | foreach ( $editors as $editor ) { |
| 43 | switch ( $editor ) { |
| 44 | case 'WP_Image_Editor_Imagick': |
| 45 | $image_editors[] = 'FooGallery_Thumb_Image_Editor_Imagick'; |
| 46 | break; |
| 47 | case 'WP_Image_Editor_GD': |
| 48 | $image_editors[] = 'FooGallery_Thumb_Image_Editor_GD'; |
| 49 | break; |
| 50 | default: |
| 51 | $image_editors[] = $editor; |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | //Make sure the order is correct |
| 56 | if ( foogallery_get_setting( 'force_gd_library', false ) ) { |
| 57 | array_splice( $image_editors, 0, 0, array('FooGallery_Thumb_Image_Editor_GD') ); |
| 58 | } |
| 59 | |
| 60 | //make sure we have a unique list of editors |
| 61 | return array_unique( $image_editors ); |
| 62 | } |
| 63 | } |
| 64 | } |
| 65 |