Skip to content

Instantly share code, notes, and snippets.

@DavidCramer
Last active June 11, 2020 13:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DavidCramer/b4daa89a1a52cf575369f7164ae77d74 to your computer and use it in GitHub Desktop.
Save DavidCramer/b4daa89a1a52cf575369f7164ae77d74 to your computer and use it in GitHub Desktop.
Alter upload settings for Cloudinary Plugin v2
<?php
add_filter( 'cloudinary_upload_options', function( $options, $attachment_post, $upload_object ){
/**
* Structure of options as follows:
$options = array(
'unique_filename' => false, // Allow for auto filenames. See Cloudinary docs.
'resource_type' => $resource_type, // Type can be 'image' or 'video' or custom.
'public_id' => $public_id, // Changing this will change the public ID as stored in Cloudinary.
'context' => array(
'caption' => esc_attr( $post->post_title ), // Set the caption data in Cloudinary.
'alt' => $post->_wp_attachment_image_alt, // set the alt text of the asset in Cloudinary
),
);
**/
// To change the asset public_id.
$options['public_id'] = $options['public_id'] . '-custom-text';
return $options;
}, 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment