Index: trunk/core/units/general/cat_dbitem.php =================================================================== diff -u -r3617 -r3709 --- trunk/core/units/general/cat_dbitem.php (.../cat_dbitem.php) (revision 3617) +++ trunk/core/units/general/cat_dbitem.php (.../cat_dbitem.php) (revision 3709) @@ -355,6 +355,27 @@ } return $columns; } + + /** + * Returns item's primary image data + * + * @return Array + */ + function getPrimaryImageData() + { + $sql = 'SELECT * + FROM '.TABLE_PREFIX.'Images + WHERE (ResourceId = '.$this->GetDBField('ResourceId').') AND (DefaultImg = 1)'; + $image_data = $this->Conn->GetRow($sql); + if (!$image_data) { + // 2. no primary image, then get image with name "main" + $sql = 'SELECT * + FROM '.TABLE_PREFIX.'Images + WHERE (ResourceId = '.$this->GetDBField('ResourceId').') AND (Name = "main")'; + $image_data = $this->Conn->GetRow($sql); + } + return $image_data; + } } ?> \ No newline at end of file