src/UriHelper.php
private static function getSrcSetUrlCustom($size, $custom, $setWidthInUrl, UriInterface $uri)
    {
        // if custom is eg '2x', add options-dpr-
        if (preg_match('#^([0-9]+)x$#', $custom, $matches)) {
            $uri = self::addOptionsToUri($uri, 'options-dpr-'.$matches[1].
                ($setWidthInUrl ? '--resize-width-'.(int) ceil($size / $matches[1]) : ''));
        } else {
            $stack = new StackUri();
            $stack->addOverridingOptions($custom);
            // if dpr is given in custom option, but not width, calculate correct width
            $resizeOperations = $stack->getStackOperationsByName('resize');
            $widthIsNotSet = true;
            foreach ($resizeOperations as $resizeOperation) {
                if (isset($resizeOperation->options['width'])) {
                    $widthIsNotSet = false;
                }
            }
            $options = $stack->getStackOptions();
            if (isset($options['dpr']) && $widthIsNotSet && $setWidthInUrl) {
                $custom .= '--resize-width-'.(int) ceil($size / $options['dpr']);
            }

            $uri = self::addOptionsToUri($uri, $custom);
        }

        return $uri;
    }
private static function getSrcSetUrlCustom($size, $custom, $setWidthInUrl, UriInterface $uri)
    {
        // if custom is eg '2x', add options-dpr-
        if (preg_match('#^([0-9]+)x$#', $custom, $matches)) {
            $uri = self::addOptionsToUri($uri, 'options-dpr-'.$matches[1].
                ($setWidthInUrl ? '--resize-width-'.(int) ceil($size / $matches[1]) : ''));
        } else {
            $stack = new StackUri();
            $stack->addOverridingOptions($custom);
            // if dpr is given in custom option, but not width, calculate correct width
            $resizeOperations = $stack->getStackOperationsByName('resize');
            $widthIsNotSet = true;
            foreach ($resizeOperations as $resizeOperation) {
                if (isset($resizeOperation->options['width'])) {
                    $widthIsNotSet = false;
                }
            }
            $options = $stack->getStackOptions();
            if (isset($options['dpr']) && $widthIsNotSet && $setWidthInUrl) {
                $custom .= '--resize-width-'.(int) ceil($size / $options['dpr']);
            }

            $uri = self::addOptionsToUri($uri, $custom);
        }

        return $uri;
    }
private static function getSrcSetUrlCustom ( $ size , $ custom , $ setWidthInUrl , UriInterface $ uri ) { // if custom is eg '2x', add options-dpr- if ( preg_match ( '#^([0-9]+)x$#' , $ custom , $ matches ) ) { $ uri = self :: addOptionsToUri ( $ uri , 'options-dpr-' . $ matches [ 1 ] . ( $ setWidthInUrl ? '--resize-width-' . ( int ) ceil ( $ size / $ matches [ 1 ] ) : '' ) ) ; } else { $ stack = new StackUri ( ) ; $ stack -> addOverridingOptions ( $ custom ) ; // if dpr is given in custom option, but not width, calculate correct width $ resizeOperations = $ stack -> getStackOperationsByName ( 'resize' ) ; $ widthIsNotSet = true ; foreach ( $ resizeOperations as $ resizeOperation ) { if ( isset ( $ resizeOperation -> options [ 'width' ] ) ) { $ widthIsNotSet = false ; } } $ options = $ stack -> getStackOptions ( ) ; if ( isset ( $ options [ 'dpr' ] ) && $ widthIsNotSet && $ setWidthInUrl ) { $ custom .= '--resize-width-' . ( int ) ceil ( $ size / $ options [ 'dpr' ] ) ; } $ uri = self :: addOptionsToUri ( $ uri , $ custom ) ; } return $ uri ; }
Adds custom options to the URL.

@param string       $size
@param string       $custom
@param bool         $setWidthInUrl
@param UriInterface $uri

@throws \RuntimeException if stack configuration can't be parsed

@return UriInterface
Adds custom options to the URL .