(key: string): any
(all: boolean): any
(arguments: {
all?: boolean,
key?: string,
default?: any,
}): anyThe _media operator gets a value from the media object. It can only be used on the web-client (Not in requests or connections). media is a data object that contains information about the current screen size of a users browser window. It contains the following data:
width: number: The width of the window in pixels.height: number: The height of the window in pixels.size: enum: One ofxs,sm,md,lg,xl,xxl. The sizes are determined by comparing the window width to the following breakpoints (in pixels):xs:width < 576pxsm:576px <= width < 768pxmd:768px <= width < 992pxlg:992px <= width < 1200pxxl:1200px <= width < 1600pxxxl:1600px <= width
Arguments
string
If the _media operator is called with a string argument, the value of the key in the media object is returned. If the value is not found, null is returned.
boolean
If the _media operator is called with boolean argument true, the entire media object is returned.
object
all: boolean: Ifallis set totrue, the entiremediaobject is returned. One ofallorkeyare required.key: string: The value of the key in themediaobject is returned. If the value is not found,null, or the specified default value is returned. One ofallorkeyare required.default: any: A value to return if thekeyis not found inmedia. By default,nullis returned if a value is not found.
Examples
Get the value of size from media:
_media: size_media:
key: sizeReturns: The value of size.
Get the entire media object:
_media: true_media:
all: trueReturns: The entire media object.
Return a default value if the value is not found:
_media:
key: does_not_exist
default: Not thereReturns: "Not there".
