/*-----------------------------------------------------------------------------------*/
/* Slider Shortcode
/*-----------------------------------------------------------------------------------*/
function ag_slider( $atts, $content = null ) {
extract(shortcode_atts(array('crop' => ''
), $atts));
$crop = ($crop) ? ' '. $crop : '';
global $slide_counter;
$slide_counter++;
$out = NULL;
$out .= '
';
$count = 1;
$firstone = 1;
foreach ($atts as $slide) {
// Find Crop Variable
while ($firstone == 1) {
if ($slide == 'No' || $slide == 'no') {
$crop = 'postnc';
} else {
$crop = 'post';
}
$firstone++;
}
// If not First One, get image Src and convert to correct thumbnail size
if (!($slide == 'Yes' || $slide == 'yes' || $slide == 'no' || $slide == 'No')) {
$image_id = get_attachment_id_from_src ($slide);
if ($image_id) {
$caption = get_post($image_id)->post_excerpt;
} else {
$caption = '';
}
$image_src = wp_get_attachment_image_src($image_id, $crop, false);
if ($image_src) {
$out .= '';
} else {
$out .= '';
}
}
$slide_counter++;
$count++;
}
$out .= '
';
return $out;
}
add_shortcode('slider', 'ag_slider');