Filtering the alt tag attribute of an image (Pro Feature)

Need help with this?
Purchase All in One SEO Pack Pro to get dedicated support from us.

Buy Now

The aioseop_image_seo_alt_tag filter hook.

Description

$alt_tag = apply_filters( 'aioseop_image_seo_alt_tag', $this->get_attribute( 'alt', $image_id ), $image_id );

This filter can be used to filter the alt tag attribute of images.


Parameters (2)

0. $value (string)
the value of the alt tag attribute.
1. $image_id (int)
the ID of the image.

Usage

The code example below can be used to change the alt tag attribute for a given post with ID 1:

add_filter( 'aioseop_image_seo_alt_tag', 'my_change_image_alt_tag', 10, 2 );

function my_change_image_alt_tag( $value, $image_id ) {
if( 1 === $image_id ) {
return 'This is the filtered alt tag attribute.';
}
return $value;
}

Defined (1)

The filter is defined in the following location(s).

pro/class-aioseop-image-seo.php (2 occurrences)

For instructions on how to use this code, please refer to our FAQ here.