How to auto rename based on current post title a media defined as featured image

I’m using import plugin that defines terrible names for featured images, downloaded .jpg files and are as well with large and illegible names, I had a plugin that renamed all featured image based on post title, bulk rename, but not Works more in wp4.7, so I’m trying to solve this:

I tried to write a plugin:

function update_file_image_name($post_id){
$post = get_post( $post_ID );
$feat_image_this_post = wp_get_attachment_url($post_id);
$feat_image_this_post = sanitize_title( $post->post_title );
}
add_action( 'save_post', 'update_file_image_name' );

I want to apply the alt alt in my featured images, but with the files of strange names, large numbers and mixed letters, will be a bad SEO. I need the images to have the name of the title of the post, and that is in the act of creating the posts.

thanks all.

Read more here: How to auto rename based on current post title a media defined as featured image

Leave a Reply

Your email address will not be published. Required fields are marked *