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".
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:
reference to undefined name 'image' Exception of type 'MindTouch.Deki.Script.Runtime.DekiScriptUndefinedNameException' was thrown. (click for details)Callstack:
at en/kb/Embedding_an_image_slideshow
at Template:ImageSlideshow
MindTouch.Deki.Script.Runtime.DekiScriptUndefinedNameException: reference to undefined name 'image' Exception of type 'MindTouch.Deki.Script.Runtime.DekiScriptUndefinedNameException' was thrown.
at MindTouch.Deki.Script.Compiler.DekiScriptExpressionEvaluation.Visit (MindTouch.Deki.Script.Expr.DekiScriptVar expr, DekiScriptExpressionEvaluationState state) [0x00000] in <filename unknown>:0
at MindTouch.Deki.Script.Expr.DekiScriptVar.VisitWith[DekiScriptExpressionEvaluationState,Range] (IDekiScriptExpressionVisitor`2 visitor, DekiScriptExpressionEvaluationState state) [0x00000] in <filename unknown>:0
at MindTouch.Deki.Script.Compiler.DekiScriptExpressionEvaluation.Evaluate (MindTouch.Deki.Script.Expr.DekiScriptAccess expr, DekiScriptExpressionEvaluationState state, Boolean evaluateProperties) [0x00000] in <filename unknown>:0
at MindTouch.Deki.Script.Compiler.DekiScriptExpressionEvaluation.Visit (MindTouch.Deki.Script.Expr.DekiScriptAccess expr, DekiScriptExpressionEvaluationState state) [0x00000] in <filename unknown>:0
at MindTouch.Deki.Script.Expr.DekiScriptAccess.VisitWith[DekiScriptExpressionEvaluationState,Range] (IDekiScriptExpressionVisitor`2 visitor, DekiScriptExpressionEvaluationState state) [0x00000] in <filename unknown>:0
at MindTouch.Deki.Script.Compiler.DekiScriptExpressionEvaluation.Visit (MindTouch.Deki.Script.Expr.DekiScriptCall expr, DekiScriptExpressionEvaluationState state) [0x00000] in <filename unknown>:0
at MindTouch.Deki.Script.Expr.DekiScriptCall.VisitWith[DekiScriptExpressionEvaluationState,Range] (IDekiScriptExpressionVisitor`2 visitor, DekiScriptExpressionEvaluationState state) [0x00000] in <filename unknown>:0
at MindTouch.Deki.Script.Compiler.DekiScriptExpressionEvaluation.Visit (MindTouch.Deki.Script.Expr.DekiScriptTernary expr, DekiScriptExpressionEvaluationState state) [0x00000] in <filename unknown>:0
at MindTouch.Deki.Script.Expr.DekiScriptTernary.VisitWith[DekiScriptExpressionEvaluationState,Range] (IDekiScriptExpressionVisitor`2 visitor, DekiScriptExpressionEvaluationState state) [0x00000] in <filename unknown>:0
at MindTouch.Deki.Script.Compiler.DekiScriptExpressionEvaluation.Visit (MindTouch.Deki.Script.Expr.DekiScriptSequence expr, DekiScriptExpressionEvaluationState state) [0x00000] in <filename unknown>:0
at MindTouch.Deki.Script.Expr.DekiScriptSequence.VisitWith[DekiScriptExpressionEvaluationState,Range] (IDekiScriptExpressionVisitor`2 visitor, DekiScriptExpressionEvaluationState state) [0x00000] in <filename unknown>:0
at MindTouch.Deki.Script.Compiler.DekiScriptExpressionEvaluation.Visit (MindTouch.Deki.Script.Expr.DekiScriptReturnScope expr, DekiScriptExpressionEvaluationState state) [0x00000] in <filename unknown>:0
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.
i like the Slideshow, but i am looking for a function to get the imagesize OR the width and height of a picture, so I could use it for correct aspect razio at the slideshow.
Some of my Pics are not 3:4, some are 4:3.
Do you know what I'm looking for?
http://developer.mindtouch.com/DekiScript/Reference/Wiki_Functions_and_Variables
ImageWidth int Width of the image, if the file is an image (9.02 or later)
ImageHeight int Height of the image, if the file is an image (9.02 or later)
But how do I use these information to patch the code above?