How to add an alt tag to the auto featured image posts?


Staff member
I'm a total beginner to the PHP, so sorry if my question will sound silly.

So, I am using a WordPress plugin called <a href="" rel="nofollow noreferrer">Automatic Featured Image Posts</a>. It does a great job creating a draft post from a newly uploaded image. Apart from the plugin, I have also added this filter to the functions.php file which adds the image into the post:

    add_filter( 'afip_new_post_content', 'myprefix_change_afip_post_content', 10, 2 );
/* Grabs the image source for the newly created image and inserts it
 * into the new post content along with a one line paragraph. */
function myprefix_change_afip_post_content( $post_content, $attachment_id ) {
    $my_uploaded_image = wp_get_attachment_image_src( $attachment_id );

    $post_content = '&lt;p&gt;This is my new uploaded image....&lt;/p&gt;';
    $post_content .= '&lt;img src="' . $my_uploaded_image[0] . '"&gt;';
    return $post_content;

So, my question is - how to add an alt image to this code? The alt image should be the same as the title of the new post. Do I have to make another function for this? I know the first thing I have to do is to add alt="" into the tag. But how do I get the title of the post to appear into the alt? Here's a link to the code of the plugin - <a href="" rel="nofollow noreferrer">enter link description here</a>