src/UriHelper.php
public static function getSrcSetUrl(UriInterface $url, $size, $custom = null, $setWidthInUrl = true)
    {
        $identifier = substr($size, -1, 1);
        $size = substr($size, 0, -1);
        switch ($identifier) {
            case 'x':
                $uri = self::addOptionsToUri($url, 'options-dpr-'.$size);

                break;
            case 'w':
                if ($setWidthInUrl) {
                    $uri = self::addOptionsToUri($url, 'resize-width-'.$size);
                } else {
                    $uri = $url;
                }

                break;
            default:
                return $url;
        }
        if (null !== $custom) {
            $uri = self::getSrcSetUrlCustom($size, $custom, $setWidthInUrl, $uri);
        }

        return $uri;
    }
public static function getSrcSetUrl(UriInterface $url, $size, $custom = null, $setWidthInUrl = true)
    {
        $identifier = substr($size, -1, 1);
        $size = substr($size, 0, -1);
        switch ($identifier) {
            case 'x':
                $uri = self::addOptionsToUri($url, 'options-dpr-'.$size);

                break;
            case 'w':
                if ($setWidthInUrl) {
                    $uri = self::addOptionsToUri($url, 'resize-width-'.$size);
                } else {
                    $uri = $url;
                }

                break;
            default:
                return $url;
        }
        if (null !== $custom) {
            $uri = self::getSrcSetUrlCustom($size, $custom, $setWidthInUrl, $uri);
        }

        return $uri;
    }
public static function getSrcSetUrl ( UriInterface $ url , $ size , $ custom = null , $ setWidthInUrl = true ) { $ identifier = substr ( $ size , - 1 , 1 ) ; $ size = substr ( $ size , 0 , - 1 ) ; switch ( $ identifier ) { case 'x' : $ uri = self :: addOptionsToUri ( $ url , 'options-dpr-' . $ size ) ; break ; case 'w' : if ( $ setWidthInUrl ) { $ uri = self :: addOptionsToUri ( $ url , 'resize-width-' . $ size ) ; } else { $ uri = $ url ; } break ; default : return $ url ; } if ( null !== $ custom ) { $ uri = self :: getSrcSetUrlCustom ( $ size , $ custom , $ setWidthInUrl , $ uri ) ; } return $ uri ; }
Returns a rokka URL to be used in srcset style attributes.

$size can be eg. "2x" or "500w"
$custom can be any rokka options you want to optionally add, or also a dpi identifier like "2x"

This method will then generate the right rokka URLs to get what you want, see
`\Rokka\Client\Tests\UriHelperTest::provideGetSrcSetUrl` for some examples and the expected returns.

@param UriInterface $url           The original rokka render URL to be adjusted
@param string       $size          The size of the image, eg '300w' or '2x'
@param null|string  $custom        Any rokka options you'd like to add, or are a dpi identifier like '2x'
@param bool         $setWidthInUrl If false, don't set the width as stack operation option, we provide it in $custom, usually as parameter

@throws \RuntimeException

@return UriInterface
Returns a rokka URL to be used in srcset style attributes .