How to embed {g->image} with scaled image in own Template

cmuth

Joined: 2009-12-28
Posts: 1
Posted: Mon, 2009-12-28 23:23

Hi folks,

i've built a custom module for gallery 2.3.1 which i plan to release under the GPL as soon as it's finished.
With the module one can create cascading categories for images, e.g. for a car gallery:
Country->Vendor->Model.
Then, admins can assign possible values to these categories, such as US, France, Germany for country and Dodge, Renault, Mercedes for vendors and so on.

Images in turn can be categorized according to these restricted values (e.g. "this car is a German one, Manufacturer is Mercedes-Benz and the Model is SL55AMG")

All went fine, my only problem so far concerns the combined view showing the cascaded filter select boxes for the categories on the top, a thumbnailed preview on the right and if a thumbnail was clicked - a slightly bigger view of the thumb on the left along with some detailed information (e.g. engine power etc.).

I don't know how to display the pre-scaled images that g2 creates when you limit image sizes per a) Gallery Setting->Scaled Images->Target Size or b) sizelimit module, which i both tried.
In the normal single item view, the image is scaled according to the settings defined, but in my own controller and template, i simply use:

$selectedItemId = (int)GalleryUtilities::_getRequestVariable('g2_selectedItemId');
if ($selectedItemId > 0) {
  $ViewFiltered['selectedItemId'] = $selectedItemId;
  list ($ret, $selectedItem) = GalleryCoreApi::loadEntitiesById($selectedItemId, 'GalleryPhotoItem');
  if ($ret) {
    return array($ret, null);
  }
  $template->setVariable('selected', (array)$selectedItem);
}

and

{if (!empty($selected)) }
  {capture assign=selectedLinkUrl}{strip}
  {g->url arg1="view=core.ShowItem" arg2="itemId=`$selected.id`"}
  {/strip}{/capture}
  <a href="{$selectedLinkUrl}">
    {g->image item=$selected image=$selected}
  </a>
  {if !empty($selected.title)}
    <p class="giTitle">{$selected.title|markup}</p>
  {/if}
{/if}

Which of course doensn't know about size limits or prescaled images and always displays the image in its native size...

How can i display the image in my own template like its done in the ordinary gallery view?

Thanks a lot in advance!

Christian