• Hello

    I would like to get the alt attribute value of each image registered using Dynamic Featured Image. I registered two images in the static home page and managed to display them using the code below but failed to display their alt attribute values:

    if(class_exists('Dynamic_Featured_Image')){
    	global $dynamic_featured_image;
    	$featured_images = $dynamic_featured_image->get_featured_images(get_the_ID);
    	$featured_image_alt =
    	$dynamic_featured_image->get_image_alt_by_id(get_the_ID);
    	$image0 = $featured_images[0];
    	$image1 = $featured_images[1];
    	$imageAlt0 = $featured_image_alt[0];
    	$imageAlt1 = $featured_image_alt[1];
    	echo '<img src="'.$image0['full'].' " alt="'.$imageAlt0.'">';
    }

    Replacing get_image_alt_by_id() with get_image_alt() returns the empty value too, so I guess I’m not following the descriptions given in the plugin’s GitHub page:

    https://github.com/ankitpokhrel/Dynamic-Featured-Image/wiki/API#8-get_image_alt-image_url-

    Please someone help me display the alt attribute values.

    Thanks for reading this.

  • The topic ‘How do you get the alt attribute values of images?’ is closed to new replies.