/** * Render an image path with HTML. * * @return string */ public function get() { $that = $this; // Using cache to reduce request. $ckey = 'attachment-' . $this->attachmentId; if (!($attachment = Cache::get($ckey))) { $attachment = $that->getAttachmentProvider()->findById($that->attachmentId); Cache::put($ckey, $attachment, 60); } // Having scale, but not generate yet! if (!is_object($attachment) and strpos($this->attachmentId, '_')) { preg_match('|(.*)_(.*)|', $this->attachmentId, $matches); $attachment = $this->resizeFromMasterFile($matches[1], $matches[2]); } if (is_object($attachment)) { $location = $attachment->getAttribute('location'); if (preg_match('/^http/', $location)) { return $location; } return $this->uploader->url($location); } $failure = array_get($this->config, 'placeholder'); return $failure instanceof Closure ? $failure($this->attachmentId, $this) : false; }