---
title: Filtrar atributos de imagen automáticos
url: "https://www.seopress.org/es/soporte/hooks/filtrar-atributos-de-imagen-automaticos/"
lang: es
updated: 2023-10-25
hook_name: seopress_auto_image_title
required_version: 3.4, 5.8, 7.1
---

# Filtrar atributos de imagen automáticos

- **Hook name:** `seopress_auto_image_title`
- **Required version:** 3.4, 5.8, 7.1

```php
function sp_auto_image_title($img_attr, $cpt, $parent, $post_ID) {
	//Check for a specific post type key
	if ($cpt === 'page') {
		$img_title = "my awesome image title";
	}

	//Check for a specific post meta
	if (get_post_meta( $post_ID, 'my_post_meta_key', true)) {
		$img_title = get_post_meta( $post_ID, 'my_post_meta_key', true);
	}

	//Same with ACF
	if (function_exists('get_field') && get_field('my_acf_field_name', $post_ID)) {
		$img_title = get_field('my_acf_field_name', $post_ID);
	}

	//uncommnent the line below to convert the first letter of each word to uppercase
	//$img_title = ucwords($img_title);

	return $img_title;
}
add_filter('seopress_auto_image_title', 'sp_auto_image_title', 10, 4);
```

Source: [https://gist.github.com/wp-seopress/20a4f05a52505e0446e1ba60c11a7dc3](https://gist.github.com/wp-seopress/20a4f05a52505e0446e1ba60c11a7dc3)



