Skip to content

Instantly share code, notes, and snippets.

@arunbasillal
Created September 8, 2022 18:02
Show Gist options
  • Save arunbasillal/924868debc1c601d2e7773ca68aad341 to your computer and use it in GitHub Desktop.
Save arunbasillal/924868debc1c601d2e7773ca68aad341 to your computer and use it in GitHub Desktop.
Add hyphens between words for Image Title in Image Attributes Pro
/**
* Add hyphens between words for Image Title in Image Attributes Pro
*
* @param $attributes (array) Associative array of image attributes.
*
* @author Arun Basil Lal
* @link https://imageattributespro.com/codex/iaffpro_image_attributes/
*/
function prefix_iap_add_hyphens_to_image_title( $attributes ) {
$attributes['title'] = trim ( $attributes['title'] );
$attributes['title'] = str_replace( ' ', '-', $attributes['title'] );
return $attributes;
}
add_filter( 'iaffpro_image_attributes', 'prefix_iap_add_hyphens_to_image_title' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment