You can use a DekiScript template to automatically select all pictures from a page for a slideshow.
First: let's create a template for our purposes; we are calling the template "ImageSlideshow".
<p>{{ <br />
var pics = map.values(wiki.getpage($0 ?? $path ?? page.path).files ?? { });<br />
let pics = list.select(pics, "string.startswith($.mime, 'image/')");<br />
let pics = list.collect(pics, "uri"); <br />
if(#pics > 0) image.slideshow(pics, $1 ?? $width ?? 320, $2 ?? $height ?? 240, 5, "slideright");<br />
}}</p>
Notice on this template I am passing in the page path as "path" and optionally the width and height of the slideshow.
Next: Use the template.
{{ template.ImageSlideshow("User:SteveB/Gallery") }}
And see the output:
Variation (contributed by Bryan Nelson)
Just paste the following code into a DekiScript section of a new template on your site.
/*
* ImageSlideshow Dekiscript Template
*
* by Bryan Nelson 16 May 2009
*
* {{ template.ImageSlideshow( path : uri ?, width: number ?, height: number ?) }}
* path : URI path to page with image attachements; Optional; Default = page.path
* width: Image width, Optional; Default = 320
* height: Image height, Optional; Default = 240
*
* This template inserts a table of thumbnails (with name and description) of all the
* images attached to a particular page.for the a page. If a page is not sepecified then the
* current page is used. If the number of columns are not specified then 3 is default.
*
* Work based on examples at
* http://developer.mindtouch.com/index.php?title=DekiScript/FAQ/How_do_I..._Embed_an_image_slideshow%3F&highlight=image+slideshow
*
* This template uses my preferred method of writing Dekiscript in the text editor and not
* the source editor to keep code formatting.
*
*/
var pics = map.values(wiki.getpage($0 ?? $path ?? page.path).files ?? { });
let pics = list.select(pics, "string.startswith($.mime, 'image/')");
let pics = list.collect(pics, "uri");
var webviewpics;
foreach(var pic in pics)
{
let webviewpics = webviewpics .. [ (pic .. "?size=webview") ];
}
if(#pics > 0)
{
image.slideshow(webviewpics, $1 ?? $width ?? 320, $2 ?? $height ?? 240, 5, "slideright");
}
From forums: http://forums.developer.mindtouch.com/showthread.php?p=24905
thanks
let pics = list.collect(pics,"URI");
but when I try to add that text"
let pics = list.collect(pics,"URI").."?size=webview";
I get an error because it doesn't want to add str to type list.
Could you elaborate on where to make the change? I've researched the list.collect function but still don't understand how to append the string to it.
Thanks for replying!
let pics = list.collect(pics,"webviewURI");
{{
/*
* ImageSlideshow Dekiscript Template
*
* by Bryan Nelson 16 May 2009
*
* {{ template.ImageSlideshow( path : uri ?, width: number ?, height: number ?) }}
* path : URI path to page with image attachements; Optional; Default = page.path
* width: Image width, Optional; Default = 320
* height: Image height, Optional; Default = 240
*
* This template inserts a table of thumbnails (with name and description) of all the
* images attached to a particular page.for the a page. If a page is not sepecified then the
* current page is used. If the number of columns are not specified then 3 is default.
*
* Work based on examples at
* http://developer.mindtouch.com/index.php?title=DekiScript/FAQ/How_do_I..._Embed_an_image_slideshow%3F&highlight=image+slideshow
*
* This template uses my preferred method of writing Dekiscript in the text editor and not
* the source editor to keep code formatting.
*
*/
var pics = map.values(wiki.getpage($0 ?? $path ?? page.path).files ?? { });
let pics = list.select(pics, "string.startswith($.mime, 'image/')");
let pics = list.collect(pics, "uri");
var webviewpics;
foreach(var pic in pics)
{
let webviewpics = webviewpics .. [ (pic .. "?size=webview") ];
}
if(#pics > 0)
{
image.slideshow(webviewpics, $1 ?? $width ?? 320, $2 ?? $height ?? 240, 5, "slideright");
}
}}
Thanks.