コード例 #1
0
 public function setup()
 {
     parent::setup();
     if ($this->enabled()) {
         add_filter('wp_update_attachment_metadata', [$this, 'updateAttachmentMetadata'], 1000, 2);
         add_filter('delete_attachment', [$this, 'deleteAttachment'], 1000);
         add_filter('wp_handle_upload', [$this, 'handleUpload'], 10000);
         add_filter('ilab-s3-process-crop', [$this, 'processCrop'], 10000, 3);
         add_filter('get_attached_file', [$this, 'getAttachedFile'], 10000, 2);
         add_filter('ilab-s3-process-file-name', function ($filename) {
             if (strpos($filename, '/' . $this->bucket) === 0) {
                 return str_replace('/' . $this->bucket, '', $filename);
             }
             return $filename;
         }, 10000, 1);
         add_action('add_attachment', function ($post_id) {
             $post = get_post($post_id);
             $file = get_post_meta($post_id, '_wp_attached_file', true);
             if (isset($this->uploadedDocs[$file])) {
                 add_post_meta($post_id, 'ilab_s3_info', $this->uploadedDocs[$file]);
             }
         }, 10000);
         add_filter('wp_calculate_image_srcset', [$this, 'calculateSrcSet'], 10000, 5);
     }
     add_filter('wp_get_attachment_url', [$this, 'getAttachmentURL'], 1000, 2);
 }
コード例 #2
0
 public function registerSettings()
 {
     parent::registerSettings();
     register_setting('ilab-imgix-preset', 'ilab-imgix-presets');
     register_setting('ilab-imgix-preset', 'ilab-imgix-size-presets');
 }
コード例 #3
0
 public function __construct($toolName, $toolInfo, $toolManager)
 {
     parent::__construct($toolName, $toolInfo, $toolManager);
 }