This photo should be used as a placeholder if the correct photo can't
be retrieved
public static getErrorImage ( string $view = 'screen' ) : string | ||
$view | string | The view ('screen', 'thumb', or 'full') to show. Defaults to 'screen'. |
return | string | The image path. |
/** * Return a link to an image, suitable for use in an <img/> tag * Takes into account $conf['vfs']['direct'] and other * factors. * * @param string $imageId The id of the image. * @param string $view The view ('screen', 'thumb', 'full', 'mini') * to show. * @param boolean $full Return a path that includes the server name? * @param Ansel_Style $style Use this gallery style * * @return Horde_Url The image path. */ public static function getImageUrl($imageId, $view = 'screen', $full = false, Ansel_Style $style = null) { global $conf; if (empty($imageId)) { return Horde::url((string) Ansel::getErrorImage($view), $full); } // Default to ansel_default if (is_null($style)) { $style = Ansel::getStyleDefinition('ansel_default'); } // Don't load the image if the view exists $viewHash = Ansel_Image::viewExists($imageId, $view, $style); if ($conf['vfs']['src'] != 'php' && $viewHash === false) { // We have to make sure the image exists first, since we won't // be going through img/*.php to auto-create it. try { $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImage($imageId); } catch (Exception $e) { Horde::log($e, 'ERR'); return Horde::url((string) Ansel::getErrorImage($view), $full); } try { $image->createView($view, $style, $GLOBALS['prefs']->getValue('watermark_auto') && $view == 'screen' ? $GLOBALS['prefs']->getValue('watermark_text', '') : ''); } catch (Ansel_Exception $e) { return Horde::url((string) Ansel::getErrorImage($view), $full); } $viewHash = $image->getViewHash($view, $style) . '/' . $image->getVFSName($view); } // First check for vfs-direct. If we are not using it, pass this off to // the img/*.php files, and check for sendfile support there. if ($conf['vfs']['src'] != 'direct') { $params = array('image' => $imageId); if (!is_null($style)) { $params['t'] = $style->thumbstyle; $params['b'] = $style->background; if ($style->width) { $params['w'] = $style->width; } if ($style->height) { $params['h'] = $style->height; } } return Horde::url('img/' . $view . '.php', $full)->add($params); } // Using vfs-direct $path = substr(str_pad($imageId, 2, 0, STR_PAD_LEFT), -2) . '/' . $viewHash; if ($full && substr($conf['vfs']['path'], 0, 7) != 'http://') { return Horde::url($conf['vfs']['path'] . $path, true, -1); } else { return new Horde_Url($conf['vfs']['path'] . htmlspecialchars($path)); } }