UriHelper
class UriHelper (View source)
Methods
Allows you to add stack options to a Rokka URL.
Allows you to add stack options to a Rokka URL.
Generate a rokka uri with an array or an UriComponent returned by decomposeUri().
Return components of a rokka URL.
No description
Returns a rokka URL to be used in srcset style attributes.
Details
static string
addOptionsToUriString(string $url, array|string $options)
Allows you to add stack options to a Rokka URL.
Useful eg. if you just want to add "options-dpr-2" to an existing URL. Returns the original URL, if it can't parse it as valid Rokka URL.
static UriInterface
addOptionsToUri(UriInterface $uri, array|string $options)
Allows you to add stack options to a Rokka URL.
Useful eg. if you just want to add "options-dpr-2" to an existing URL Returns the original URL, if it can't parse it as valid Rokka URL.
Example with string as input
UriHelper::addOptionsToUri($uri, 'options-dpr-2--resize-upscale-false');
Example with array
UriHelper::addOptionsToUri($uri,
[
'options' => ['dpr' => 2],
'operations' =>
[
[
'name' => 'resize',
'options' => ['upscale' => 'false']
],
],
]);
static UriInterface
composeUri(array|UriComponents $components, UriInterface $uri = null)
Generate a rokka uri with an array or an UriComponent returned by decomposeUri().
The array looks like
['stack' => 'stackname', #or StackUri object
'hash' => 'hash',
'filename' => 'filename-for-url',
'format' => 'image format', # eg. jpg
]
static UriComponents|null
decomposeUri(UriInterface $uri)
Return components of a rokka URL.
static UriInterface
getSrcSetUrlString(string $url, string $size, null|string $custom = null)
No description
static UriInterface
getSrcSetUrl(UriInterface $url, string $size, null|string $custom = null)
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.