Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save badabingbreda/9015e04255779af88d47873b314e0ee2 to your computer and use it in GitHub Desktop.
Save badabingbreda/9015e04255779af88d47873b314e0ee2 to your computer and use it in GitHub Desktop.
Toolbox Example - Adding custom classes to acfimage
<?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