PHP Class Bkwld\Croppa\URL

Mostra file Open project: bkwld/croppa Class Usage Examples

Public Methods

Method Description
__construct ( array $config = [] ) Inject dependencies
buildFilters ( array $options ) : array | null Build filter class instancees
generate ( string $url, integer $width = null, integer $height = null, array $options = null ) : string Insert Croppa parameter suffixes into a URL. For use as a helper in views when rendering image src attributes.
options ( string $option_params ) : array Create options array where each key is an option name and the value if an array of the passed arguments
parse ( string $request ) : array | boolean Parse a request path into Croppa instructions
pathToUrl ( string $path ) : string Append host to the path if it was defined
phpThumbConfig ( array $options ) : array Take options in the URL and options from the config file and produce a config array in the format that PhpThumb expects
relativePath ( string $url ) : string Take a URL or path to an image and get the path relative to the src and crops dirs by using the path config regex
routePattern ( ) : string Make the regex for the route definition. This works by wrapping both the basic Croppa pattern and the path config in positive regex lookaheads so they working like an AND condition.
signingToken ( $url ) : string | void Generate the signing token from a URL or path. Or, if no key was defined, return nothing.
toPath ( string $url ) : string Extract the path from a URL and remove it's leading slash

Method Details

__construct() public method

Inject dependencies
public __construct ( array $config = [] )
$config array

buildFilters() public method

Build filter class instancees
public buildFilters ( array $options ) : array | null
$options array
return array | null Array of filter instances

generate() public method

Insert Croppa parameter suffixes into a URL. For use as a helper in views when rendering image src attributes.
public generate ( string $url, integer $width = null, integer $height = null, array $options = null ) : string
$url string URL of an image that should be cropped
$width integer Target width
$height integer Target height
$options array Addtional Croppa options, passed as key/value pairs. Like array('resize')
return string The new path to your thumbnail

options() public method

Create options array where each key is an option name and the value if an array of the passed arguments
public options ( string $option_params ) : array
$option_params string Options string in the Croppa URL style
return array

parse() public method

Parse a request path into Croppa instructions
public parse ( string $request ) : array | boolean
$request string
return array | boolean | boolean

pathToUrl() public method

Append host to the path if it was defined
public pathToUrl ( string $path ) : string
$path string Request path (with leading slash)
return string

phpThumbConfig() public method

Take options in the URL and options from the config file and produce a config array in the format that PhpThumb expects
public phpThumbConfig ( array $options ) : array
$options array The url options from `parseOptions()`
return array

relativePath() public method

Take a URL or path to an image and get the path relative to the src and crops dirs by using the path config regex
public relativePath ( string $url ) : string
$url string url or path
return string

routePattern() public method

https://regex101.com/r/kO6kL1/1 In the Laravel router, this gets wrapped with some extra regex before the matching happnens and for the pattern to match correctly, the final .* needs to exist. Otherwise, the lookaheads have no length and the regex fails https://regex101.com/r/xS3nQ2/1
public routePattern ( ) : string
return string

signingToken() public method

Generate the signing token from a URL or path. Or, if no key was defined, return nothing.
public signingToken ( $url ) : string | void
return string | void

toPath() public method

Extract the path from a URL and remove it's leading slash
public toPath ( string $url ) : string
$url string
return string path