app/MediaFile.php
public function imageUrl($width, $height, $fit): string
    {
        // Sign the URL, to protect against mass-resize attacks.
        $glide_key = Site::getPreference('glide-key');
        if (empty($glide_key)) {
            $glide_key = bin2hex(random_bytes(128));
            Site::setPreference('glide-key', $glide_key);
        }

        if (Auth::accessLevel($this->media->tree()) > $this->media->tree()->getPreference('SHOW_NO_WATERMARK')) {
            $mark = 'watermark.png';
        } else {
            $mark = '';
        }

        $url_builder = UrlBuilderFactory::create(WT_BASE_URL, $glide_key);

        $url = $url_builder->getUrl('index.php', [
            'route'     => 'media-thumbnail',
            'xref'      => $this->media->xref(),
            'ged'       => $this->media->tree()->name(),
            'fact_id'   => $this->fact_id,
            'w'         => $width,
            'h'         => $height,
            'fit'       => $fit,
            'mark'      => $mark,
            'markh'     => '100h',
            'markw'     => '100w',
            'markalpha' => 25,
            'or'        => 0,
            // Intervention uses exif_read_data() which is very buggy.
        ]);

        return $url;
    }
public function imageUrl($width, $height, $fit): string
    {
        // Sign the URL, to protect against mass-resize attacks.
        $glide_key = Site::getPreference('glide-key');
        if (empty($glide_key)) {
            $glide_key = bin2hex(random_bytes(128));
            Site::setPreference('glide-key', $glide_key);
        }

        if (Auth::accessLevel($this->media->tree()) > $this->media->tree()->getPreference('SHOW_NO_WATERMARK')) {
            $mark = 'watermark.png';
        } else {
            $mark = '';
        }

        $url_builder = UrlBuilderFactory::create(WT_BASE_URL, $glide_key);

        $url = $url_builder->getUrl('index.php', [
            'route'     => 'media-thumbnail',
            'xref'      => $this->media->xref(),
            'ged'       => $this->media->tree()->name(),
            'fact_id'   => $this->fact_id,
            'w'         => $width,
            'h'         => $height,
            'fit'       => $fit,
            'mark'      => $mark,
            'markh'     => '100h',
            'markw'     => '100w',
            'markalpha' => 25,
            'or'        => 0,
            // Intervention uses exif_read_data() which is very buggy.
        ]);

        return $url;
    }
public function imageUrl ( $ width , $ height , $ fit ) : string { // Sign the URL, to protect against mass-resize attacks. $ glide_key = Site :: getPreference ( 'glide-key' ) ; if ( empty ( $ glide_key ) ) { $ glide_key = bin2hex ( random_bytes ( 128 ) ) ; Site :: setPreference ( 'glide-key' , $ glide_key ) ; } if ( Auth :: accessLevel ( $ this -> media -> tree ( ) ) > $ this -> media -> tree ( ) -> getPreference ( 'SHOW_NO_WATERMARK' ) ) { $ mark = 'watermark.png' ; } else { $ mark = '' ; } $ url_builder = UrlBuilderFactory :: create ( WT_BASE_URL , $ glide_key ) ; $ url = $ url_builder -> getUrl ( 'index.php' , [ 'route' => 'media-thumbnail' , 'xref' => $ this -> media -> xref ( ) , 'ged' => $ this -> media -> tree ( ) -> name ( ) , 'fact_id' => $ this -> fact_id , 'w' => $ width , 'h' => $ height , 'fit' => $ fit , 'mark' => $ mark , 'markh' => '100h' , 'markw' => '100w' , 'markalpha' => 25 , 'or' => 0 , // Intervention uses exif_read_data() which is very buggy. ] ) ; return $ url ; }
Generate a URL for an image.

@param int    $width  Maximum width in pixels
@param int    $height Maximum height in pixels
@param string $fit    "crop" or "contain"

@return string
Generate a URL for an image .