Skip to content

Commit

Permalink
Fixes #724, Only retrieves files with derivative images when using th…
Browse files Browse the repository at this point in the history
…e item_image helper.
  • Loading branch information
davelester committed Apr 29, 2009
1 parent 529b2b8 commit 142065e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
5 changes: 3 additions & 2 deletions application/helpers/NewThemeFunctions.php
Expand Up @@ -801,8 +801,9 @@ function item_image($imageType, $props = array(), $index = 0, $item = null)
if (!$item) {
$item = get_current_item();
}

$imageFile = $item->Files[$index];

$imageFile = get_db()->getTable('File')->findWithImages($item->id, $index);

$width = @$props['width'];
$height = @$props['height'];

Expand Down
19 changes: 19 additions & 0 deletions application/models/FileTable.php
Expand Up @@ -59,4 +59,23 @@ public function findByItem($item_id, $fileIds = array())
}
return $this->fetchObjects($select, array($item_id));
}

/**
* Retrieve file that has derivative images.
*
* @param integer $itemId
* @param integer $index Optional If given, this specifies the file to
* retrieve for an item, based upon the ordering of its derivative files.
*
* @return array
**/
public function findWithImages($item_id, $index=0)
{
$select = $this->getSelect()
->where('f.item_id = ? AND f.has_derivative_image = 1')
->order('f.item_id ASC')
->limitPage($index, 1);

return $this->fetchObject($select, array($item_id));
}
}

0 comments on commit 142065e

Please sign in to comment.