function data_image($pData, $pParams) { global $gBitSystem, $gBitSmarty; $ret = ' '; $imgStyle = ''; $wrapper = liberty_plugins_wrapper_style($pParams); $description = !isset($wrapper['description']) ? $wrapper['description'] : NULL; foreach ($pParams as $key => $value) { if (!empty($value)) { switch ($key) { // rename a couple of parameters case 'width': case 'height': if (preg_match("/^\\d+(em|px|%|pt)\$/", trim($value))) { $imgStyle .= $key . ':' . $value . ';'; } elseif (preg_match("/^\\d+\$/", $value)) { $imgStyle .= $key . ':' . $value . 'px;'; } // remove values from the hash that they don't get used in the div as well $pParams[$key] = NULL; break; } } } $wrapper = liberty_plugins_wrapper_style($pParams); if (!empty($pParams['src'])) { $thumbUrl = $pParams['src']; } elseif (@BitBase::verifyId($pParams['id']) && $gBitSystem->isPackageActive('fisheye')) { require_once FISHEYE_PKG_PATH . 'FisheyeImage.php'; $gBitSmarty->loadPlugin('smarty_modifier_display_bytes'); $item = new FisheyeImage($pParams['id'], NULL); if ($item->load()) { // insert source url if we need the original file if (!empty($pParams['size']) && $pParams['size'] == 'original') { $thumbUrl = $item->getDownloadUrl(); } elseif ($item->mInfo['thumbnail_url']) { $thumbUrl = !empty($pParams['size']) && !empty($item->mInfo['thumbnail_url'][$pParams['size']]) ? $item->mInfo['thumbnail_url'][$pParams['size']] : $item->mInfo['thumbnail_url']['medium']; } if (empty($description)) { $description = !isset($wrapper['description']) ? $wrapper['description'] : $item->getField('title', tra('Image')); } } } // check if we have a valid thumbnail if (!empty($thumbUrl)) { // set up image first $ret = '<img' . ' alt="' . $description . '"' . ' title="' . $description . '"' . ' src="' . $thumbUrl . '"' . ' style="' . $imgStyle . '"' . ' />'; if (!empty($pParams['nolink'])) { } elseif (!empty($wrapper['link'])) { // if this image is linking to something, wrap the image with the <a> $ret = '<a href="' . trim($wrapper['link']) . '">' . $ret . '</a>'; } elseif (empty($pParams['size']) || $pParams['size'] != 'original') { if ($gBitSystem->isFeatureActive('site_fancy_zoom') and !empty($item->mInfo['source_url'])) { $ret = '<a href="' . trim(str_replace(' ', '%20', $item->mInfo['source_url'])) . '">' . $ret . '</a>'; } else { if ($item->getDownloadUrl()) { $ret = '<a href="' . trim($item->getDownloadUrl()) . '">' . $ret . '</a>'; } else { if (!empty($item->mInfo['media_url'])) { $ret = '<a href="' . trim($item->mInfo['media_url']) . '">' . $ret . '</a>'; } } } } if (!empty($wrapper['style']) || !empty($class) || !empty($wrapper['description'])) { $ret = '<' . $wrapper['wrapper'] . ' class="' . (!empty($wrapper['class']) ? $wrapper['class'] : "img-plugin") . '" style="' . $wrapper['style'] . '">' . $ret . (!empty($wrapper['description']) ? '<br />' . $wrapper['description'] : '') . '</' . $wrapper['wrapper'] . '>'; } } else { $ret = tra("Unknown Image"); } return $ret; }