예제 #1
0
파일: Imgjss.php 프로젝트: elvendor/imgjss
 /**
  * Process given image path.
  *
  * @return string
  */
 public function img($path, $attrs = [], $timestamp = null, $secure = null)
 {
     // Here is a little trick:
     // by default in Laravel's HTML::image we pass 'alt' attribute as second param
     // and other attributes as third. A little weird, right? Let's fix that!
     return HTML::image($this->process($path, null, $timestamp), isset($attrs['alt']) ? $attrs['alt'] : null, $attrs, $secure);
 }
 public function addFormMacro()
 {
     app('form')->macro('captcha', function ($options = array()) {
         $image = \Illuminate\Support\Facades\HTML::image(Captcha::img(), 'Captcha Image');
         $label = "<label for=\"captcha\">Enter the Captcha</label> ";
         $input = "<input type=\"text\"  name=\"captcha\" id=\"captcha\" autcomplete=\"off\" required/>";
         return $image . $label . $input;
     });
 }
예제 #3
0
 /**
  * Renders the thumbnail of the model.
  *
  * @param string|null $size
  * @param array       $attributes
  *
  * @return string
  */
 public function thumbnail($size = null, $attributes = [])
 {
     if (!$this->thumb) {
         $upload = $this->getUploadClass();
         $upload = $upload::getPlaceholder($this->getClassBasename());
         return HTML::image($upload);
     }
     return $this->thumb->render($size, $attributes);
 }
예제 #4
0
 public function image($email, $alt = null, $attributes = array(), $rating = null)
 {
     $dimensions = array();
     if (array_key_exists('width', $attributes)) {
         $dimensions[] = $attributes['width'];
     }
     if (array_key_exists('height', $attributes)) {
         $dimensions[] = $attributes['height'];
     }
     $max_dimension = count($dimensions) ? min(512, max($dimensions)) : $this->default_size;
     $src = $this->src($email, $max_dimension, $rating);
     if (!array_key_exists('width', $attributes) && !array_key_exists('height', $attributes)) {
         $attributes['width'] = $this->size;
         $attributes['height'] = $this->size;
     }
     return HTML::image($src, $alt, $attributes);
 }
예제 #5
0
 /**
  * Renders the image at a certain size.
  *
  * @param string|null $size
  * @param array       $attributes
  *
  * @return string
  */
 public function render($size = null, $attributes = [])
 {
     $url = $this->file->url($size);
     $path = $this->file->path();
     if (!file_exists($path)) {
         $type = $this->hasIllustrable() ? $this->illustrable->getClassBasename() : null;
         $url = static::getPlaceholder($type);
     }
     return HTML::image($url, null, $attributes);
 }
예제 #6
0
 /**
  * Add an image asset to the container.
  * 
  * @param string $source
  * @param string $alt
  * @param array  $attributes
  * 
  * @return string
  */
 public function image($source, $alt = null, $attributes = array())
 {
     $url = $source;
     if (false === strstr($source, '://') && '//' !== substr($source, 0, 2)) {
         $url = $this->cdn($source);
     }
     return HTML::image($url, $alt, $attributes);
 }