Filters

Imgix/Dynamic Images Filters

media-cloud/dynamic-images/enabled

Returns if either dynamic images feature (either Imgix or Dynamic Images) is enabled.

$enabled = apply_filters('media-cloud/dynamic-images/enabled', false);

 

media-cloud/imgix/enabled

Returns if the Imgix, specifically, is enabled.

$enabled = apply_filters('media-cloud/imgix/enabled', false);

 

media-cloud/glide/enabled

Returns if the Dynamic Images, specifically, is enabled.

$enabled = apply_filters('media-cloud/glide/enabled', false);

 

media-cloud/imgix/alternative-formats/enabled

Returns if alternative formats are enabled for Imgix.

$enabled = apply_filters('media-cloud/imgix/alternative-formats/enabled', false);

 

media-cloud/imgix/detect-faces

Returns if Imgix face detection is enabled.

$enabled = apply_filters('media-cloud/imgix/detect-faces', false);

 

media-cloud/imgix/render-pdf

Returns if Imgix PDF rendering is enabled.

$enabled = apply_filters('media-cloud/imgix/render-pdf', false);

 

media-cloud/dynamic-images/filter-parameters

Allows dynamic image parameters (Imgix or Dynamic Images) to be changed.

add_filter('media-cloud/dynamic-images/filter-parameters', function($parameters, $imageSize, $attachmentId, $attachmentMeta) {
    if ($imageSize == 'some-size') {
        $parameters['fit'] = 'crop';
    }

    return $parameters;
}, 1000, 4);

 

Cloud Storage Filters

media-cloud/storage/after-upload

This filter allows for filtering of an attachment's metadata after it has been uploaded to cloud storage.

add_filter('media-cloud/storage/after-upload', function($attachmentMeta, $attachmentId) {
    // do something here
    return $attachmentMeta;
}, 1000, 2);

 

media-cloud/storage/can-calculate-srcset

Determines if Media Cloud should calculate the srcset for an image.

add_filter('media-cloud/storage/can-calculate-srcset', function($canCalculateSrcSet) {
    return $canCalculateSrcSet;
});

 

media-cloud/storage/can-filter-content

Controls if Media Cloud should filter a post's content.

add_filter('media-cloud/storage/can-filter-content', function($canFilterContent) {
    return $canFilterContent;
});

 

media-cloud/storage/ignore-metadata-update

This filter can be used to temporarily suspend Media Cloud's processing of attachment metadata.

add_filter('media-cloud/storage/ignore-metadata-update', function($shouldIgnore, $attachmentId) {
    return $shouldIgnore;
}, 1000, 2);

 

media-cloud/storage/ignore-existing-s3-data

Forces Media Cloud to ignore an attachment's existing cloud storage metadata when processing an attachment.

add_filter('media-cloud/storage/ignore-existing-s3-data', function($shouldIgnore, $attachmentId) {
    return $shouldIgnore;
}, 1000, 2);

 

media-cloud/storage/ignore-optimizers

Forces Media Cloud to ignore the fact that image optimizer plugins are installed and activated.

add_filter('media-cloud/storage/ignore-optimizers', function($shouldIgnore, $attachmentId) {
    return $shouldIgnore;
}, 1000, 2);

 

media-cloud/storage/process-file-name

Filters a given filename, removing any storage related parts from the path, eg the bucket name.

$filename = apply_filters('media-cloud/storage/process-file-name', $filename);

 

media-cloud/storage/should-handle-upload

Controls if Media Cloud should process a WordPress upload.

add_filter('media-cloud/storage/should-handle-upload', function($shouldHandle, $uploadData) {
    return $shouldHandle;
}, 1000, 2);

 

media-cloud/storage/should-override-attached-file

Media Cloud will typically intercept get_attached_file() and return the storage URL if that file is no longer present on the local filesystem. If the file is on the local filesystem, get_attached_file() will return the file path to it. This filter allows you to override this behavior.

add_filter('media-cloud/storage/should-override-attached-file', function($shouldOverride, $attachment_id) {
    return $shouldOverride;
}, 1000, 2);

 

media-cloud/storage/should-use-custom-prefix

Allows the use of custom prefixes on uploads to be overridden from whatever the setting currently is.

add_filter('media-cloud/storage/should-use-custom-prefix', function($shouldUseCustomPrefix) {
    return $shouldUseCustomPrefix;
});

 

media-cloud/storage/upload-master

Controls if the master/main image is uploaded to cloud storage.

add_filter('media-cloud/storage/upload-master', function($shouldUpload) {
    return $shouldUpload;
});

 

Vision Filters

media-cloud/vision/detect-faces

Returns if Vision is enabled and set to detect faces.

$detectingFaces = apply_filters('media-cloud/vision/detect-faces', false);

 

media-cloud/vision/process-meta

Processes an attachment's metadata with Vision. If Vision is setup to process in background, this processing will then take place later.

$attachmentMeta = apply_filters('media-cloud/vision/process-meta', $attachmentMeta, $attachmentId);

 

Direct Upload Filters

media-cloud/direct-uploads/max-uploads

Overrides the setting for the maximum number of uploads.

add_filter('media-cloud/direct-uploads/max-uploads', function($maxUploads) {
    return min(4, $maxUploads);
});

 

Actions

media-cloud/imgix/setup

This action is triggered once the Imgix feature is configured and ready to use. This will not be triggered if the tool is not enabled.

add_action('media-cloud/imgix/setup', function() {
    // Imgix is setup and ready
});

 

media-cloud/direct-uploads/process-batch

After files have been uploaded with Direct Upload, this action is called with the attachment IDs so that other tools can process the attachments.

add_action('media-cloud/direct-uploads/process-batch', function($postIds) {
    // Do something with the post IDs.
});

 

media-cloud/storage/register-drivers

Registers any additional or custom cloud storage drivers.

add_action('media-cloud/storage/register-drivers', function() {
    StorageManager::registerDriver('my-storage-driver-key', 'My Storage Driver', MyNamespace\MyStorageDriver::class, [], []);
});

 

media-cloud/storage/uploaded-attachment

This is fired once an upload has been added.

add_action('media-cloud/storage/uploaded-attachment', function($attachmentId, $fileName, $uploadData) {
    // Do something
}, 1000, 3);

 

media-cloud/tools/register-tools

Register any custom tool with Media Cloud.

add_action('media-cloud/tools/register-tools', function() {
    ToolsManager::registerTool('my-tool', []);
});

 

media-cloud/vision/register-drivers

Register any additional vision drivers. This action is only called with the paid version.

add_action('media-cloud/vision/register-drivers', function() {
    VisionManager::registerDriver('my-vision-driver', 'My Vision Driver', MyNamespace\MyVisionDriver::class, [], []);
});

 

Ultimate Member Integration Filters

media-cloud/integrations/ultimate-member/glide-params

Allows any Dynamic Image image parameters to be supplied when creating urls for Ultimate Member. This action is only called with the pro version.

add_filter('media-cloud/integrations/ultimate-member/glide-params', function($umKey, $params) {
    // Add a blur to cover photos
    if ($umKey == 'cover_photo') {
        $params['blur'] = 20;
    }

    return $params;
}, 1000, 2);

 

media-cloud/integrations/ultimate-member/imgix-params

Allows any Imgix image parameters to be supplied when creating urls for Ultimate Member. This action is only called with the pro version.

add_filter('media-cloud/integrations/ultimate-member/imgix-params', function($umKey, $params) {
    // Add a blur to cover photos
    if ($umKey == 'cover_photo') {
        $params['blur'] = 20;
    }

    return $params;
}, 1000, 2);

   

Deprecated Filters and Actions

Filters

Deprecated Filter New Filter
ilab_s3_after_upload media-cloud/storage/after-upload
ilab_s3_should_handle_upload media-cloud/storage/should-handle-upload
ilab_s3_can_calculate_srcset media-cloud/storage/can-calculate-srcset
ilab_media_cloud_filter_content media-cloud/storage/can-filter-content
ilab_storage_should_use_custom_prefix media-cloud/storage/should-use-custom-prefix
ilab-imgix-filter-parameters media-cloud/dynamic-images/filter-parameters

 

Actions

Deprecated Action New Action
ilab_imgix_setup media-cloud/imgix/setup