Last active
June 11, 2020 13:08
-
-
Save DavidCramer/b4daa89a1a52cf575369f7164ae77d74 to your computer and use it in GitHub Desktop.
Alter upload settings for Cloudinary Plugin v2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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