Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save arunbasillal/566dd144625ce9dbc7fbd2b22e53e102 to your computer and use it in GitHub Desktop.

Select an option

Save arunbasillal/566dd144625ce9dbc7fbd2b22e53e102 to your computer and use it in GitHub Desktop.
IAP: Preserve triple hyphens while generating image attributes.
/**
* Preserve triple hyphens while generating image attributes.
*
* Replace triple hyphens in image (---) with a placeholder (IAPHYPHEN) in the image filename.
* Image Attributes Pro already replaces IAPHYPHEN back to a single hyphen ( - ) after applying filters
* in iaffpro_image_name_from_filename().
*
* @param $image_name (string) Name of the image.
* @return $image_name (string) Name of the image with triple hyphens replaced by IAPHYPHEN
*
* @author Arun Basil Lal
* @link https://imageattributespro.com/codex/iaffpro_image_name_from_filename_pre/
*/
function prefix_iap_preserve_triple_hyphens( $image_name ) {
return str_replace( '---', 'IAPHYPHEN', $image_name ); // Adds a placeholder.
}
add_filter( 'iaffpro_image_name_from_filename_pre', 'prefix_iap_preserve_triple_hyphens' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment