• Hi,
    I’m modifying one WP theme and I’d really like to add a simple attribute to gallery shortcode whether to crop image thumbnail or not. And then in the process of creating a thumbnail I would like to just specify

    if crop == 'yes' { do this }
    else { do that }

    Is that possible? And if so than how? Thanks for any answer!

    Edit:
    Theme has it’s own registered gallery shortcode with some modifications I think, but I simply can’t make this work…

Viewing 1 replies (of 1 total)
  • Thread Starter Swayne3

    (@swayne3)

    Ok, got it. Just added ‘crop’ into

    extract( shortcode_atts( array(
    		'order'      => 'ASC',
    		'orderby'    => 'menu_order ID',
    		'id'         => $post->ID,
    		'itemtag'    => 'dl',
    		'icontag'    => 'dt',
    		'captiontag' => 'dd',
    		'columns'    => 5,
    		'size'       => 'gallery',
    		'exclude'    => '',
    		'include'    => '',
    		'ids'	     => '',
    		'crop'	     => ''
    	), $attr ) );

    then
    $crop = tag_escape($crop);
    and at the end

    if ( $crop == "yes" )
         $img_src = crop function
    else
         $img_src = normal resize

    But now I have to manually add ‘crop=”yes”‘ to the shortcode in the post editor. Is there a way to implement simple dropdown select with only two options ‘Crop Yes/No’ into Gallery editor?

Viewing 1 replies (of 1 total)
  • The topic ‘Adding custom attribute to [gallery] shortcode’ is closed to new replies.