/** * Генерирует код для миниатюры * * @param string $file * @param string $preset */ public static function getThumbCode($file, $preset = 'image.medium') { $file = UPLOADS . $file; $thumbnail = image_preset($preset, $file, TRUE); $preset = str_replace('.', '-', $preset); return HTML::a(File::pathToUri($file), self::getCode($thumbnail), array('class' => 'preset ' . $preset)); }
<?php $thumb = File::pathToUri(image_preset('image.thumb', UPLOADS . DS . $file->path)); ?> <a class="fancybox sh" href="<?php echo $file->getLink(); ?> " class="file-<?php echo $file->info->getExtension(); ?> "> <img src="<?php echo $thumb; ?> "> </a>
/** * Render avatar * * @param string $file */ public function render($preset = 'avatar.small') { $file = UPLOADS . '/' . $this->file; return HTML::img(Url::toUri(image_preset($preset, $file)), $this->object->login, array('class' => 'avatar')); }
/** * Get HTML image avatar * * @param string $preset * @return string */ public function getAvatarImage($preset = 'avatar.small') { return HTML::img(image_preset($preset, $this->getAvatar()->getFile(), TRUE), $this->login, array('class' => 'avatar', 'title' => $this->getName())); }
/** * Render avatar * * @param string $file */ public function render($preset = 'avatar.small') { return HTML::img(Url::toUri(image_preset($preset, $this->getFile())), $this->object()->login, array('class' => 'avatar')); }
<?php if ($value && file_exists(UPLOADS . $value)) { ?> <div class="image-preview"><img src="<?php echo File::pathToUri($element->options->preset ? image_preset($element->options->preset, UPLOADS . $value) : UPLOADS . $value); ?> "></div> <label class="checkbox"><input type="checkbox" name="<?php echo $element->name; ?> " value=""/> <?php echo t('Удалить'); ?> </label> <?php } else { echo HTML::input($element->options); } ?>