Working on the code provided by asbrown, I’ve made some updates so that the modified plugin works when auto-inserted.
First, I added a function in general-template.php to grab the link array. I added it right after the boom_get_header_images function, around line 59.
/**
* ADDED TO GRAB LINKS FOR auto_insert FUNCTION ON header-image-slider.php - m.
* Returns a one dimensional array of header image links.
*
* 6/30/12
*/
function boom_get_header_image_links() {
$available_links = array();
if( get_theme_mod( 'header_image', '' ) == 'boom-slider-uploaded' ) {
$available_links = unserialize(get_option( 'boom_available_headers_links' ));
} else {
return array();
}
return $available_links;
}
Second, I modified the auto_insert function in header-image-slider.php to call the function above, and to insert the anchor if the link value was not blank. I simply commented the current version of auto_insert, and dropped this one in below it, around line 270.
/**
* THIS IS THE UN-MINIFIED VERSION OF THE CODE ABOVE, FIXED TO USE LINKS PROPERLY - m.
*
* 6/30/12
*/
function auto_insert() {
if( boom_slider_get_option('autoinsert') ) : ?>
<script>
jQuery(function($){
function boom_build_slider( slides ) {
imgs = '';
$.each(slides, function(i, value){
if (slidelinks[i] != "") { imgs += '<a href="' + slidelinks[i] + '"><img src="' + value + '" alt="" /></a>' }
else { imgs += '<img src="' + value + '" alt="" />' };
});
return '<div class="slider-wrapper theme-default"><div class="ribbon"></div><div class="nivoSlider headerSlider">'+ imgs +'</div></div>';
}
var slides = <?php echo str_replace("\\/", "/", json_encode( boom_get_header_images() ) ) ?>;
var slidelinks = <?php echo str_replace("\\/", "/", json_encode( boom_get_header_image_links() ) ) ?>;
var $header = $('img[src="https://boom-slider-default"], img[src="https://boom-slider-uploaded"]');
var $parent = $header.parent();
if( $parent.is('a') ) { // in case the header image is wrapped in a link, also remove the link
$parent.after( boom_build_slider(slides) ).remove();
} else {
$header.after( boom_build_slider(slides) ).remove();
}
var $slider = $('div.headerSlider');
$slider.find('img:first').load(function(){ // we have to wait for an image to be loaded to get the width and height
var width = $(this).width(),
height = $(this).height();
$slider.css({
'width': width,
'height': height
}).nivoSlider({
<?php echo boom_nivo_slider_options() ?>
})
});
});
</script>
<?php endif;
}
You’ll notice that I used the non-minified version of auto_insert that I found in the 0.2 build on the subversion repository. I’m not sure what, if anything, might break when using this earlier version of auto_insert, but my php and javascript aren’t strong enough to modify the minified version.