/** * Return a valid img tag for an image. * * @param Omeka_Record_AbstractRecord $record * @param array $props Image tag attributes * @param string $format Derivative image type (thumbnail, etc.) * @return string */ public function image_tag($record, $props, $format) { if (!($record && $record instanceof Omeka_Record_AbstractRecord)) { return false; } // Use the default representative file. $file = $record->getFile(); if (!$file) { return false; } if ($file->hasThumbnail()) { $uri = $file->getWebPath($format); } else { $uri = img($this->_getFallbackImage($file)); } $props['src'] = $uri; /** * Determine alt attribute for images * Should use the following in this order: * 1. passed 'alt' prop * 2. first Dublin Core Title for $file * 3. original filename for $file */ $alt = ''; if (isset($props['alt'])) { $alt = $props['alt']; } else { if ($fileTitle = metadata($file, 'display title', array('no_escape' => true))) { $alt = $fileTitle; } } $props['alt'] = $alt; $title = ''; if (isset($props['title'])) { $title = $props['title']; } else { $title = $alt; } $props['title'] = $title; // Build the img tag return '<img ' . tag_attributes($props) . '>'; }