Created
June 18, 2018 19:22
-
-
Save badabingbreda/9015e04255779af88d47873b314e0ee2 to your computer and use it in GitHub Desktop.
Toolbox Example - Adding custom classes to acfimage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'toolbox/helpers/sc_attr/type=image' , 'add_image_class_attr' , 10 ,1 ); | |
// add a custom attribute named 'myclass' | |
function add_image_class_attr( $attr ) { | |
$attr['myclass'] = ''; | |
return $attr; | |
} | |
add_filter( 'toolbox/helpers/set_acfimage_classes' , 'enable_custom_image_classes', 10, 2 ); | |
// add the custom atrtibute 'myclass' to the $classes array | |
function enable_custom_image_classes( $classes , $attr ) { | |
if (isset($attr['myclass']) && $attr['myclass'] !='' ) { | |
array_push( $classes , $attr['myclass'] ); | |
} | |
return $classes; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment