Process image

@param string $url
@param int    $width
@param int    $height
@param string $title
@param array  $options

@param string
765490
public function process($url, $width = '', $height = '', $title = '', $options = [])
    {
        //If invalid URL passed, set to default image
        if (empty($url) || filter_var($url, FILTER_VALIDATE_URL) === false) {
            $url = $this->defaultImage;
        }

        $data = json_encode([
            'url' => $url,
            'width' => $width,
            'height' => $height,
            'default' => $this->defaultImage,
            'options' => array_merge($this->defaultOptions, $options)
        ]);

        $uri = base64_encode(json_encode([
            'data' => $data,
            'hash' => sha1($this->key.$this->secret.$data)
        ]));

        // Make the b64 string url-safe
        $uri = str_replace(['+', '/'], ['-', '_'], $uri);

        $fullUrl = [
            $this->host,
            $this->key,
            $uri,
            $this->filename($url, $title)
        ];

        return implode('/', $fullUrl);
    }
483488
private function loadImageFromURL($url)
    {
        $image = $this->fetchImageContentFromURL($url);

        if (empty($image)) {
            return;
        }

        if (Utils::isJPGResource($image)) {
            $this->filename = $url;
            $this->extension = 'jpg';
            $this->type = IMAGETYPE_JPEG;
        }

        if (Utils::isPNGResource($image)) {
            $this->filename = $url;
            $this->extension = 'png';
            $this->type = IMAGETYPE_PNG;
        }

        $this->from = 'external';
        $this->resource = imagecreatefromstring($image);
        $this->width = $this->boxWidth = imagesx($this->resource);
        $this->height = $this->boxHeight = imagesy($this->resource);
    }
382467
public function append($title, $url, array $options = array()) {
        $this->_crumbs[] = array(
            'title' => strip_tags($title),
            'url' => $url,
            'options' => $options
        );

        $this->OpenGraph->title($this->pageTitle(null, array('reverse' => true)));
        $this->OpenGraph->uri($url);

        return $this;
    }
903336
private static function resizeImage(array $src = [], array $dst = [], array $options = []): void
    {
        $srcImg = $src['function']($src['file']);
        $dstImg = \imagecreatetruecolor($dst['size']['w'], $dst['size']['h']);

        if (\in_array($src['type'], [IMAGETYPE_GIF, IMAGETYPE_PNG])) {
            $trIdx = \imagecolortransparent($srcImg);

            if ($trIdx > 0) {
                $trData = \imagecolorsforindex($srcImg, $trIdx);
                $background = \imagecolorallocate($dstImg, $trData['red'], $trData['green'], $trData['blue']);
                \imagefill($dstImg, 0, 0, $background);
                \imagecolortransparent($dstImg, $background);
            } elseif ($src['type'] == IMAGETYPE_PNG) {
                \imagealphablending($dstImg, false);
                $background = \imagecolorallocatealpha($dstImg, 0, 0, 0, 127);
                \imagefill($dstImg, 0, 0, $background);
                \imagesavealpha($dstImg, true);
            }
        }

        \imagecopyresampled(
            $dstImg,
            $srcImg,
            0,
            0,
            $dst['size']['src-box']['x'],
            $dst['size']['src-box']['y'],
            $dst['size']['w'],
            $dst['size']['h'],
            $dst['size']['src-box']['w'],
            $dst['size']['src-box']['h']
        );

        if ($options['gs'] === true) {
            \imagefilter($dstImg, IMG_FILTER_GRAYSCALE);
        }

        if (Directory::exists(\dirname($dst['file'])) === false) {
            Directory::create(\dirname($dst['file']));
        }

        $dst['function']($dstImg, $dst['file'], $dst['quality']);
    }
322868
public function setImageUrl($imageUrl = '')
	{
		$this->imageUrl = $imageUrl;
		$imageSizes = @getimagesize($this->imageUrl);
		if ($imageSizes)
		{
			list($this->imageWidth, $this->imageHeight) = $imageSizes;
		}
		else
		{
			$this->setError('Unable to get details of image');
		}
	}
431743
function (url, onImageReady, applyAutocrop) {
            var _this = this;

            this.toggleLoadingImage(true);
            this.clear();
            this._applyAutocrop = (applyAutocrop !== false);

            this._image = new IMSoftcrop.Image(
                IMSoftcrop.Ratio.hashFnv32a(url),
                this
            );

            this._image.load(
                url,
                function () {
                    _this.setZoomToImage(false);
                    _this.centerImage(false);
                    _this.updateImageInfo(false);

                    if (_this._autocrop) {
                        _this.detectDetails();
                        _this.detectFaces();
                    }
                    else {
                        _this.toggleLoadingImage(false);
                    }

                    _this.applySoftcrops();
                    _this.redraw();

                    if (typeof onImageReady === 'function') {
                        onImageReady.call(_this, _this._image);
                    }
                }
            );
        }
435667
public function image($image, $width=null, $height=null, $alt=null, $class=null, $link=null, $caption=null, $srcset=null) {
		$image = $this->getLink($image);
		$attributes = $this->getHtmlAttributes(array(
			'width'=>$width,
			'height'=>$height,
			'alt'=>$alt,
			'caption'=>$caption,
			'class'=>$class,
			'srcset'=>$srcset
		));

		$img = "<img src='$image'$attributes />";
		if (!is_null($link)) {
			$link = $this->getLink($link);
			return "<a href='$link'>$img</a>";
		}

		return $img;
	}
490067
public static function cancel($title = null, $url = null, array $options = [])
    {
        $toolbar = Toolbar::getInstance(self::$_toolbar);
        $options += [
            'icon'      => 'close',
            'iconClass' => 'ckTextRed',
            'button'    => 'grey lighten-3'
        ];

        if (empty($url)) {
            $url = ['action' => 'index'];
        }

        $title = (empty($title)) ? __d('core', 'Cancel') : $title;

        $toolbar->appendButton('Core.link', $title, $url, $options);
    }
82731
public function prepend($title, $url, array $options = array()) {
        array_unshift($this->_crumbs, array(
            'title' => strip_tags($title),
            'url' => $url,
            'options' => $options
        ));

        $this->OpenGraph->title($this->pageTitle(null, array('reverse' => true)));
        $this->OpenGraph->uri($url);

        return $this;
    }
613616
public function render(?string $url = null): void
	{
		// Get HTML element
		$el = $this->getElementPrototype();
		$el->size = $this->size;
		$el->annotation = $this->annotation;

		// Set given URL or filled url
		if ($url !== null) {
			Validators::assert($url, 'string|url');
			$el->href = $url;
		} else {
			$el->href = $this->url;
		}

		// Set width in INLINE mode
		if ($this->annotation === self::ANNOTATION_INLINE) {
			$el->width = $this->width;
		}

		// Set callback, if filled
		if ($this->callback !== null) {
			$el->callback = $this->callback;
		}

		// Set properties as data attributes
		foreach ($this->getProperties() as $key => $value) {
			if ($value !== null && !empty($value)) {
				$el->{'data-' . $key} = $value;
			}
		}

		echo $el;
	}
1028069
public function add($title, $url, array $options = array()) {
        $this->append($title, $url, $options);

        return $this;
    }
392701
function (url) {
            if (this.$.width) {
                url += ",width=" + ImageService.normalizeImageSize(this.$.width);
            }

            if (this.$.height) {
                url += ",height=" + ImageService.normalizeImageSize(this.$.height);
            }

            return url;
        }
794540
public function postLink($title, $url = null, $options = array(), $confirmMessage = false) {
		$exit = false;
		if (isset($options['onHide'])){
			list($url,$options,$exit)= $this->_onHide($url,$options);
		}
		return  ($exit)? false : parent::postLink($title,$url,$options,$confirmMessage);		
	}
313844
public function setDefaultImage($url)
    {
        if (filter_var($url, FILTER_VALIDATE_URL) === false) {
            throw new \InvalidArgumentException('Invalid Default Image URL');
        }

        $this->defaultImage = $url;
    }
293090
public function updateURL(&$url)
    {
        // Skip if resampling is off, or is already resampled, or is not an image
        if (!Config::inst()->get(get_class($this), 'force_resample') || $this->getVariant() || !$this->getIsImage()) {
            return;
        }

        // Attempt to resample
        $resampled = $this->Resampled();
        if (!$resampled) {
            return;
        }

        // Only update if resampled file is a smaller file size
        if ($resampled->getAbsoluteSize() < $this->getAbsoluteSize()) {
            $url = $resampled->getURL();
        }
    }
399460
protected function processLinkUrl($url)
    {
        $_html  = !empty($url[0]) ? $url[0] : '';
        $_url   = $_html;
        $_title = $_html;

        // --------------------------------------------------------------------------

        //  Only process if there's a URL to process
        if ($_html && $_url) {
            $_html = $this->processLinkGenerate($_html, $_url, $_title, false);
        }

        return $_html;
    }
495983
public function link($title, $url = null, array $options = [])
    {
        $options = optionsParser($options, ['escape' => false, 'title' => $title]);
        $options->add('title', trim(h(strip_tags($options->get('title')))))->tooltip();
        list($title, $options) = $this->addIconToText($title, $options);

        return parent::link($title, $url, $options->toArray());
    }