Thats a great idea rogermh, I already voted. ??
I really needed this functionality now so Im afraid I cannot wait anymore till the developers implement this so I made a solution for myself. And hopefully you guys can make use of this too.
Basically what I did was to make use of the Description meta data for placing my custom URL instead of the Link URL since its not going to save any link you put there anyway. Not until the developers do something about this. So maybe for now we can use this as a simple workaround.
Simply put this code into your functions.php
// Custom Gallery
function custom_gallery() {
$args = array(
'post_type' => 'attachment',
'numberposts' => -1,
'post_status' => null,
'post_parent' => get_the_id()
);
$attachments = get_posts($args);
if ($attachments) :
echo '<div class="gallery-' . get_the_id() . '">';
foreach ($attachments as $attachment) {
echo '<div class="gallery-item">';
$attachment = get_post( $attachment->ID );
if ($attachment->post_content == '') :
$attachment_url = $attachment->guid;
else :
$attachment_url = $attachment->post_content;
endif;
echo '<a rel="shadowbox[album-' . get_the_id() . '];" href="' . $attachment_url . '">';
echo wp_get_attachment_image($attachment->ID, $size='thumbnail', $icon = false);
echo '</a>';
echo '</div><!--.gallery-item-->';
}
echo '</div><!--.gallery-' . get_the_id() . '-->';
endif;
}
add_shortcode('custom-gallery', 'custom_gallery');
Now this will work by typing the shortcode [custom-gallery] into your post editor.
If you want to use this in your theme you can simply put the following code and it will also work as long as its inside the loop where $post->ID is available.
<?php echo do_shortcode('[custom-gallery]'); ?>
And now you can give your images custom URLs so you can link them to other sites or videos or anything. Just put the link in the Description field and save. When left blank your image will be linked to the attachment file.
Im using the shadowbox-js plugin in my gallery because it supports a wide variety of media. Try this together with the code I provided and you can be able to view images and videos from youtube or vimeo while browsing your galleries.
Look for this code and delete it if you’re not going to use it. Although its fine if you just leave it.
rel="shadowbox[album-' . get_the_id() . '];"
You can also assign custom thumbnail sizes. Just look for the word thumbnail in the code and replace it with your custom thumbnail size. You can refer to this tutorial for further understanding about custom thumbnails.
I hope this helps. ??