/** * Returns an image URL for a image preview (with url to thumbs.php or just a reference to the scaled image) * * @param mixed $fileInfo Is a file path or an array containing a file info from tx_dam::file_compileInfo(). * @param string $size Optional: $size is [w]x[h] of the image preview. 56 is default. * @param mixed $imgAttributes additional attributes for the image tag * @return array Thumbnail image url and attributes with width/height: array('url' => $url, 'attributes' => $imgAttributes); */ function previewImgUrl($fileInfo, $size = '', $imgAttributes = '') { $thumb = tx_dam_image::preview($fileInfo, $size, $imgAttributes); return $thumb['url']; }
/** * Returns meta data which might be processed. * That means some fields are known and will be substituted by other fields values if the requested field is empty. * Example if you request a caption but the field is empty you will get the description field value. * This function will be improved by time and the processing will be configurable. * * @param string $field Field name to get meta data from. These are database fields. * @param array $conf Additional configuration options for the field rendering (if supported for field) * @return mixed Meta data value. * @todo getContent(): more fields and user fields */ function getContent($field, $conf = array()) { global $TYPO3_CONF_VARS; require_once PATH_txdam . 'lib/class.tx_dam_guifunc.php'; $content = ''; $hsc = true; switch ($field) { case 'file_size': if (!$conf['format']) { $conf['format'] = 'filesize'; } $content = $this->getMetaInfo($field); break; case '__image_thumbnailImgTag': $content = tx_dam_image::previewImgTag($this->getMetaInfoArray(), $conf['size'], $conf['imgAttributes']); $hsc = false; break; case '__image_thumbnailImgUrl': $content = tx_dam_image::previewImgUrl($this->getMetaInfoArray(), $conf['size'], $conf['imgAttributes']); $hsc = false; break; case '__image_thumbnailImg': $content = tx_dam_image::preview($this->getMetaInfoArray(), $conf['size'], $conf['imgAttributes']); // This is an array - return directly return $content; break; case '__icon_fileTypeImgTag': $addAttrib = $conf['imgAttributes']; if ($conf['createTitleAttribute'] and strpos($addAttrib, 'title=') === false) { $addAttrib .= tx_dam_guiFunc::icon_getTitleAttribute($this->getMetaInfoArray()); } $content = tx_dam::icon_getFileTypeImgTag($this->getMetaInfoArray(), $conf['imgAttributes']); $hsc = false; break; case 'caption': $caption = $this->getMeta('caption'); if (!$caption) { $caption = $this->getMeta('description'); } $content = $caption; break; case 'alt_text': $alt_text = $this->getMeta('alt_text'); if (!$alt_text) { $alt_text = $this->getMeta('title'); } $content = $alt_text; break; case 'media_type': $content = tx_dam_guifunc::convert_mediaType($this->getMeta($field)); break; // TODO set substitution rules externally // TODO allow user functions // TODO set substitution rules externally // TODO allow user functions default: $content = $this->getMetaInfo($field); break; } if ($conf['format'] and $content) { $content = tx_dam_guifunc::tools_formatValue($content, $conf['format'], $conf['formatConf']); } if ($conf['stdWrap.']) { $lcObj = t3lib_div::makeInstance('tslib_cObj'); $lcObj->start($this->getMetaArray(), 'tx_dam'); $content = $lcObj->stdWrap($content, $conf['stdWrap.']); $hsc = false; } else { } if (isset($conf['htmlSpecialChars']) and !$conf['htmlSpecialChars']) { $hsc = false; } if ($hsc or $conf['htmlSpecialChars']) { $content = htmlspecialchars($content); } return $content; }