Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Custom tag %image_alt_text% for Image Attributes Pro.
/**
* Custom tag %image_alt_text% for Image Attributes Pro.
*
* @param $image_id The ID of the image that is being updated.
* @param $parent_post_id The post to which the image is attached (uploaded) to.
* @param $bulk True when called from Bulk Updater. False by default.
*
* @return (string) Image alt text from Media Library.
*/
function iaffpro_get_custom_attribute_tag_image_alt_text( $image_id, $parent_post_id, $bulk = false ) {
// Retrieve image alt text
$alt_text = get_post_meta( $image_id, '_wp_attachment_image_alt', true );
// Return image alt text if it exist. Empty string otherwise.
return $alt_text ? $alt_text : '';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment