]> git.decadent.org.uk Git - memories.git/blobdiff - templates/photo/sized
Merge commit 'trunk'
[memories.git] / templates / photo / sized
diff --git a/templates/photo/sized b/templates/photo/sized
new file mode 100644 (file)
index 0000000..c0a0f10
--- /dev/null
@@ -0,0 +1,30 @@
+<div class="photoview" id="photoview">
+    [% SET sizes = request.config.sizes %]
+    [% IF request.params.exists("scale") %]
+        [% SET size =  request.params.scale  %]
+    [% ELSIF request.session.scale %]
+        [% SET size =  request.session.scale  %]
+    [% ELSE; SET size =  1; END; %]
+    <img src="[% photo.sized_url(size) %]" id="thephoto">
+    <p> (Original size [%photo.dimensions %]) </p>
+    <p>
+    <script> function change_size(size) { 
+        new Ajax.Updater("photoview", "[%base%]/photo/sized/[%photo.id%]?scale="+size);
+    } </script>
+    Size: 
+    [% SET i = 0; WHILE i < sizes.size %]
+        [% IF photo.is_bigger(sizes.$i);  %]
+            [% IF i == size %]
+                [% sizes.$i %]
+            [% ELSIF sizes.$i == "full" %]
+                <a href="[%photo.path("url")%]">full</a>
+            [% ELSE %]
+                <a href="javascript:change_size([%i%])">[% sizes.$i %]</a>
+            [% END %]
+        [% END; %] 
+    [% SET i = i + 1 %]
+    [% END %]
+    </p>
+    [%# Now put it back in the session %]
+    [% SET request.session.scale = size %]
+</div>