Tuesday 27 June 2006 4:24:03 am
I have a really slow thumbnail page that I'm trying to speed up by making an extension for listing the thumbnails. I want to make some SQL to list the images, find a particular image variation and display the thumbnail linked to the URL alias of the image. Problem is, I can't find documentation on how to get a particular image variation from the image XML stored in the database. I assume there must be some functions that already handle this. I also want to re-generate the thumbnail if there's been any updates to the image object or the thumbnail doesn't already exist. I'm not sure if this will actually be any faster than just doing it from a template, but I'd still like to learn how to do it just as an excercise.
Here's the page: http://daniel.staver.no/home/gallery/buildings/chimney_v The thumbnails on the left side account for about 85% of the processing time. The page takes about 1.7 seconds to generate even with compiling and viewcaching switched on. I'd really like this page to display much faster. Here's the code I'm using:
{def $parent=$node.parent}
<h3>Images in {$parent.name}</h3>
{def
$images = fetch( content, list, hash(
parent_node_id, $parent.node_id,
sort_by, array( published, false() )
))
}
{cleanup_whitespace}
{section loop=$images}
<div class="image">
{if $:item.node_id|eq($node.node_id)}
<img src={$:item.data_map.image.content.squarethumb_selected.url|ezurl} alt="{$:item.name}" />
{else}
<a href={$:item.url_alias|ezurl()}><img src={$:item.data_map.image.content.squarethumb.url|ezurl} alt="{$:item.name}" /></a>
{/if}
</div>
{/section}
{/cleanup_whitespace}
Any suggestions? I don't want to use a cache block for this as I need to highlight the selected image which means the menu will change on every page.
Daniel Staver
http://daniel.staver.no
|