24.10 Quarta-Feira
A não perder
Ainda não é esta noite que vamos dormir.
/** * Auto Add Image Attributes From Image Filename * * @author Arun Basil Lal * @refer https://millionclues.com/?p=3908 * @plugin https://wordpress.org/plugins/auto-image-attributes-from-filename-with-bulk-updater/ */ function abl_mc_auto_image_attributes( $post_ID ) { $attachment = get_post( $post_ID ); $attachment_title = $attachment->post_title; $attachment_title = str_replace( '-', ' ', $attachment_title ); // Hyphen Removal $attachment_title = ucwords( $attachment_title ); // Capitalize First Word $uploaded_image = array(); $uploaded_image['ID'] = $post_ID; $uploaded_image['post_title'] = $attachment_title; // Image Title wp_update_post( $uploaded_image ); update_post_meta( $post_ID, '_wp_attachment_image_alt', $attachment_title ); // Image Alt Text } add_action( 'add_attachment', 'abl_mc_auto_image_attributes' );
Ainda não é esta noite que vamos dormir.