private static function ContentFirstImageLookup($root, $img, $size) { # Get base name and extension $info = path::info($img); $base = $info['base']; if (preg_match('/^\\.(.+)_(sq|t|s|m)$/', $base, $m)) { $base = $m[1]; } $res = false; if ($size != 'o' && file_exists($root . '/' . $info['dirname'] . '/.' . $base . '_' . $size . '.jpg')) { $res = '.' . $base . '_' . $size . '.jpg'; } else { $f = $root . '/' . $info['dirname'] . '/' . $base; if (file_exists($f . '.' . $info['extension'])) { $res = $base . '.' . $info['extension']; } elseif (file_exists($f . '.jpg')) { $res = $base . '.jpg'; } elseif (file_exists($f . '.png')) { $res = $base . '.png'; } elseif (file_exists($f . '.gif')) { $res = $base . '.gif'; } } if ($res) { return $res; } return false; }
/** * Constructor * * Creates an instance of fileItem object. * * @param string $file Absolute file or directory path * @param string $root File root path * @param string $root_url File root URL */ public function __construct($file, $root, $root_url = '') { $file = path::real($file); $stat = stat($file); $path = path::info($file); $rel = preg_replace('/^' . preg_quote($root, '/') . '\\/?/', '', $file); $this->file = $file; $this->basename = $path['basename']; $this->dir = $path['dirname']; $this->relname = $rel; $this->file_url = str_replace('%2F', '/', rawurlencode($rel)); $this->file_url = $root_url . $this->file_url; $this->dir_url = dirname($this->file_url); $this->extension = $path['extension']; $this->mtime = $stat[9]; $this->size = $stat[7]; $this->mode = $stat[2]; $this->uid = $stat[4]; $this->gid = $stat[5]; $this->w = is_writable($file); $this->d = is_dir($file); $this->f = is_file($file); $this->x = file_exists($file . '/.'); $this->del = files::isDeletable($file); $this->type = $this->d ? null : files::getMimeType($file); $this->type_prefix = preg_replace('/^(.+?)\\/.+$/', '$1', $this->type); }
private static function ContentFirstImageLookup($root, $img, $size) { global $core; # Get base name and extension $info = path::info($img); $base = $info['base']; try { $media = new dcMedia($core); $sizes = implode('|', array_keys($media->thumb_sizes)); if (preg_match('/^\\.(.+)_(' . $sizes . ')$/', $base, $m)) { $base = $m[1]; } $res = false; if ($size != 'o' && file_exists($root . '/' . $info['dirname'] . '/.' . $base . '_' . $size . '.jpg')) { $res = '.' . $base . '_' . $size . '.jpg'; } elseif ($size != 'o' && file_exists($root . '/' . $info['dirname'] . '/.' . $base . '_' . $size . '.png')) { $res = '.' . $base . '_' . $size . '.png'; } else { $f = $root . '/' . $info['dirname'] . '/' . $base; if (file_exists($f . '.' . $info['extension'])) { $res = $base . '.' . $info['extension']; } elseif (file_exists($f . '.jpg')) { $res = $base . '.jpg'; } elseif (file_exists($f . '.jpeg')) { $res = $base . '.jpeg'; } elseif (file_exists($f . '.png')) { $res = $base . '.png'; } elseif (file_exists($f . '.gif')) { $res = $base . '.gif'; } elseif (file_exists($f . '.JPG')) { $res = $base . '.JPG'; } elseif (file_exists($f . '.JPEG')) { $res = $base . '.JPEG'; } elseif (file_exists($f . '.PNG')) { $res = $base . '.PNG'; } elseif (file_exists($f . '.GIF')) { $res = $base . '.GIF'; } } } catch (Exception $e) { $core->error->add($e->getMessage()); } if ($res) { return $res; } return false; }
protected function imageThumbRemove($f) { $p = path::info($f); $thumb = sprintf($this->thumb_tp, '', $p['base'], '%s'); foreach ($this->thumb_sizes as $suffix => $s) { try { parent::removeFile(sprintf($thumb, $suffix)); } catch (Exception $e) { } } }
echo '<p><img src="' . $file->media_thumb[$thumb_size] . '?' . time() * rand() . '" alt="" /></p>'; } elseif ($thumb_size == 'o') { $S = getimagesize($file->file); $class = $S[1] > 500 ? ' class="overheight"' : ''; unset($S); echo '<p id="media-original-image"' . $class . '><img src="' . $file->file_url . '?' . time() * rand() . '" alt="" /></p>'; } echo '<p>' . __('Available sizes:') . ' '; foreach (array_reverse($file->media_thumb) as $s => $v) { $strong_link = $s == $thumb_size ? '<strong>%s</strong>' : '%s'; printf($strong_link, '<a href="' . $core->adminurl->get('admin.media.item', array_merge($page_url_params, array("size" => $s, 'tab' => 'media-details-tab'))) . '">' . $core->media->thumb_sizes[$s][2] . '</a> | '); } echo '<a href="' . $core->adminurl->get('admin.media.item', array_merge($page_url_params, array("size" => "o", "tab" => "media-details-tab"))) . '">' . __('original') . '</a>'; echo '</p>'; if ($thumb_size != 'o' && isset($file->media_thumb[$thumb_size])) { $p = path::info($file->file); $alpha = $p['extension'] == 'png' || $p['extension'] == 'PNG'; $thumb = sprintf($alpha ? $core->media->thumb_tp_alpha : $core->media->thumb_tp, $p['dirname'], $p['base'], '%s'); $thumb_file = sprintf($thumb, $thumb_size); $T = getimagesize($thumb_file); $stats = stat($thumb_file); echo '<h3>' . __('Thumbnail details') . '</h3>' . '<ul>' . '<li><strong>' . __('Image width:') . '</strong> ' . $T[0] . ' px</li>' . '<li><strong>' . __('Image height:') . '</strong> ' . $T[1] . ' px</li>' . '<li><strong>' . __('File size:') . '</strong> ' . files::size($stats[7]) . '</li>' . '<li><strong>' . __('File URL:') . '</strong> <a href="' . $file->media_thumb[$thumb_size] . '">' . $file->media_thumb[$thumb_size] . '</a></li>' . '</ul>'; } } // Show player if relevant if ($file_type[0] == 'audio') { echo dcMedia::audioPlayer($file->type, $file->file_url, $core->adminurl->get("admin.home", array('pf' => 'player_mp3.swf')), null, $core->blog->settings->system->media_flash_fallback); } if ($file_type[0] == 'video') { echo dcMedia::videoPlayer($file->type, $file->file_url, $core->adminurl->get("admin.home", array('pf' => 'player_flv.swf')), null, $core->blog->settings->system->media_flash_fallback); }
public function imageThumbRemove($f) { $p = path::info($f); $alpha = $p['extension'] == 'png' || $p['extension'] == 'PNG'; $thumb = sprintf($alpha ? $this->thumb_tp_alpha : $this->thumb_tp, '', $p['base'], '%s'); foreach ($this->thumb_sizes as $suffix => $s) { try { parent::removeFile(sprintf($thumb, $suffix)); } catch (Exception $e) { } } }