Changing Public Id
-
Hey,
After doing some digging, I see that there’s a filter ‘cloudinary_id’ (cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-media.php:695) which seems to allow changing the public id when uploading.
I tried adding the following:add_filter( 'cloudinary_id', 'prefix_get_cloudinary_public_id', 10, 2 ); function prefix_get_cloudinary_public_id( $public_id, $attachment_id ) { $public_id_from_db = prefix_get_cloudinary_id_by_attachment_id( $attachment_id ); if ( empty( $public_id_from_db ) ) { global $wpdb; $wpdb->insert( "{$wpdb->prefix}prefix_images", [ 'attachment_id' => $attachment_id ] ); $public_id_from_db = prefix_get_cloudinary_id_by_attachment_id( $attachment_id ); if ( ! empty( $public_id_from_db ) ) { $public_id = $public_id_from_db; } } return $public_id; }
but this doesn’t seem to work.
Some debugging shows that the hook is called and the public id output is correct (its numeric), but is seems like the file name is used anyways.Is there something wrong with my implementation? Or maybe this hook doesn’t do what I think it does.
I’m using the plugin’s latest version (2.1.2), WP version 5.3.2.
Thanks.
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Changing Public Id’ is closed to new replies.