I would like to change the markup created by from what is it as standard (dl) to a unordered-list with a difference. Below is the desired markup:
<ul>
<li><a href="/path/to/image.jpg"><img src="/path/to/image.jpg" /></a></li>
<li><a href="/path/to/image2.jpg"><img src="/path/to/image2.jpg" /></a></li>
<!-- And so on, all in one ul -->
</ul>
I want the main image source for the link & img, as I want to run the img src through a php cropper script.
Is this possible? I’m sure we can crack it!
Thanks for your replies, Jan & Rarst. They pointed me in the right direction. Here’s what I ended up with.
This disables shortcodes in the content. Perfect for this site & the function gets attached images & spits them out as a list. (I found the function somewhere & slimmed it down a little)
This is the call in single.php
This spits out a list exactly how I wanted it.
Once again, thanks guys!
Output of items in
gallery_shortcode()
function is not filtered, so no opportunity to change it there. Markup can only be replaced in full, usingpost_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 throughwp_get_attachment_link
hook with plenty of details: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()
?If you want change
dl
lists toul
lists on all galleries, not only on those that request this via extra attributes, you can hook into thepost_gallery
filter that gets run at the beginning of thegallery_shortcode
function. There you can override and set default values for the attributes.The final output is not filtered, but I guess it should be possible to remove the default shortcode handler for
gallery
, and add your own function that wrapsgallery_shortcode()
but adds final processing at the end. Or try hooking intowp_get_attachment_link
, as Rarst suggests.This is the way I’m doing it right now. I’ve got 2 codes, one for displaying the gallery shortcode, and another one for displaying the rest of the content:
The first code is:
And the second one: