/** * @param \File $f * @param null $usePictureTag */ public function __construct(\File $f = null, $usePictureTag = null) { if (!is_object($f)) { return false; } if (isset($usePictureTag)) { $this->usePictureTag = $usePictureTag; } else { $this->loadPictureSettingsFromTheme(); } if ($this->usePictureTag) { if (!isset($this->theme)) { $c = \Page::getCurrentPage(); $this->theme = $c->getCollectionThemeObject(); } $sources = array(); $fallbackSrc = $f->getRelativePath(); foreach ($this->theme->getThemeResponsiveImageMap() as $thumbnail => $width) { $type = \Concrete\Core\File\Image\Thumbnail\Type\Type::getByHandle($thumbnail); if ($type != NULL) { $src = $f->getThumbnailURL($type->getBaseVersion()); $sources[] = array('src' => $src, 'width' => $width); if ($width == 0) { $fallbackSrc = $src; } } } $this->tag = \Concrete\Core\Html\Object\Picture::create($sources, $fallbackSrc); } else { // Return a simple image tag. $this->tag = \HtmlObject\Image::create($f->getRelativePath()); $this->tag->width($f->getAttribute('width')); $this->tag->height($f->getAttribute('height')); } }
/** * Build a new Media Object * * @param string $image Image URL * @param string $title Title * @param string $content Content */ public function __construct($image, $title, $content) { $this->addClass('media'); $image = Image::create($image); $figure = Element::figure($image)->class('media-object'); $body = Element::div()->class('media-body'); $title = Element::h2($title)->class('media-heading'); $this->nest(array('figure' => $figure, 'body' => $body->nest(array('title' => $title, 'content' => $content)))); }
public function output() { $img = new Image(); $img->src($this->getPath())->class('u-avatar')->alt($this->userInfo->getUserName()); return (string) $img; }
/** * Add a plain image * * @param string $image */ protected function addPlainImage($image) { $image = $this->present($image); // Else just assume we were given an image path if (!String::contains($image, '<img')) { $image = HtmlImage::create($image); } return $this->nest(Element::create('li', $image)->addClass('thumbnail')); }
public function testCanCreateList() { $image = Image::create('foo.jpg', 'foo'); $matcher = $this->getMatcher('img', null, array('src' => 'foo.jpg', 'alt' => 'foo')); $this->assertHTML($matcher, $image); }
public function fallback($src) { $img = Image::create(); $img->src($src); $this->setChild($img); }