What we can do is that, whenever image is uploaded, based on image name, we can fill the meta data so that we can make sure they are not empty.
Paste below code in your theme’s functions.php file
add_action( 'add_attachment', 'set_image_meta_data_on_upload' );
function set_image_meta_data_on_upload( $post_ID ) {
// Check if uploaded file is an image, else do nothing
if ( wp_attachment_is_image( $post_ID ) ) {
$image_title = get_post( $post_ID )->post_title;
$image_title = preg_replace( '%\s*[-_\s]+\s*%', ' ', $my_image_title );
$image_title = ucwords( strtolower( $my_image_title ) );
$image_meta = array(
'ID' => $post_ID,
'post_title' => $image_title,
'post_excerpt' => $image_title,
'post_content' => $image_title,
);
update_post_meta( $post_ID, '_wp_attachment_image_alt', $image_title );
wp_update_post( $image_meta );
}
}
If you wish, later you can change the meta data as per your choice.
Let me know if that works for you.
]]>Thanks for you reply.
I wasn’t even considering making changes in core files ??
The option you provided was something I found already but that’s not what I’m looking for. I need a way to make them required even when it’s only when they are added as a feature image or if they are added to the content of a post.
If that’s not possible a way to alter the html printed their would be awesome, so that I can add the “required” value on those fields and add an extra paragraph with some extra guidelines.
Any idea if this would be possible?
Thx
Joren