Hello mporsild,
Open up /wp-content/themes/[your_theme]/lib/shortcodes/24-miscellaneous.php and at the bottom of the file you should see this,
}
?>
Right before that add this,
/**
*
*/
function random( $atts = null, $content = null ) {
if( $atts == 'generator' ) {
$option = array(
'name' => __( 'random', MYSITE_ADMIN_TEXTDOMAIN ),
'value' => 'random',
'options' => array(
array(
'name' => __( 'Images URL', MYSITE_ADMIN_TEXTDOMAIN ),
"desc" => __( 'Paste all of the image URLs that you would like to randomize here.', MYSITE_ADMIN_TEXTDOMAIN ),
'id' => 'content',
'type' => 'textarea',
),
array(
'name' => __( 'Type', MYSITE_ADMIN_TEXTDOMAIN ),
'desc' => __( 'Choose which type of frame you wish to use.', MYSITE_ADMIN_TEXTDOMAIN ),
'id' => 'style',
'default' => '',
'options' => array(
'border' => __( 'Transparent Border', MYSITE_ADMIN_TEXTDOMAIN ),
'reflect' => __( 'Reflection', MYSITE_ADMIN_TEXTDOMAIN ),
'framed' => __( 'Framed', MYSITE_ADMIN_TEXTDOMAIN ),
'shadow' => __( 'Shadow', MYSITE_ADMIN_TEXTDOMAIN ),
'reflect_shadow' => __( 'Reflection + Shadow', MYSITE_ADMIN_TEXTDOMAIN ),
'framed_shadow' => __( 'Framed + Shadow', MYSITE_ADMIN_TEXTDOMAIN ),
'none' => __( 'None', MYSITE_ADMIN_TEXTDOMAIN ),
),
'type' => 'select'
),
array(
'name' => __( 'Image Height <small>(optional)</small>', MYSITE_ADMIN_TEXTDOMAIN ),
'desc' => __( 'You can set the image height here. Leave this blank if you do not want to resize your image.', MYSITE_ADMIN_TEXTDOMAIN ),
'id' => 'height',
'default' => '',
'type' => 'text'
),
array(
'name' => __( 'Image Width <small>(optional)</small>', MYSITE_ADMIN_TEXTDOMAIN ),
'desc' => __( 'You can set the image width here. Leave this blank if you do not want to resize your image.', MYSITE_ADMIN_TEXTDOMAIN ),
'id' => 'width',
'default' => '',
'type' => 'text'
),
'shortcode_has_atts' => true,
)
);
return $option;
}
extract(shortcode_atts(array(
'style' => '',
'height' => '',
'width' => '',
'link_to' => 'true',
'prettyphoto' => 'true'
), $atts));
if( preg_match_all( '!http://.+\.(?:jpe?g|png|gif)!Ui', $content, $matches ) ){
$images = array();
foreach ( $matches[0] as $img ) {
array_push($images, $img);
}
}
shuffle($images);
if (isset($width)) { $width = ' width = "'.$width.'"'; }
if (isset($height)) { $height = ' height = "'.$height.'"'; }
if ($style != 'none') { return do_shortcode('[image_frame '.$width.$height.' style = "'.$style.'"]'.$images[0].'[/image_frame]'); }
else { return '<img src = "'.$images[0].'" />'; }
}
You can then use it like so,
[random style = "none" height="100" width="200"]
http://www.yoursite.com/images/1.jpg
http://www.yoursite.com/images/2.jpg
http://www.yoursite.com/images/3.jpg
[/random]