Output of items in gallery_shortcode()
function is not filtered, so no opportunity to change it there. Markup can only be replaced in full, using post_gallery
filter that runs at start of it. It's a little unconventional comparing to usual filtering end result and is probably for performance reasons (generating gallery can be considerably computationally heavy).
But it uses wp_get_attachment_link()
to generate links and its output is filtered through wp_get_attachment_link
hook with plenty of details:
apply_filters( 'wp_get_attachment_link', "<a href='$url' title='$post_title'>$link_text</a>", $id, $size, $permalink, $icon, $text );
Do you need to perform some really complex crop that you want separate script to handle it?Why not let WP handle it with add_image_size()
?