Skip to content

Mux Element Query Variables

This documentation covers all available query variables for Mux assets in Craft CMS. Each variable includes examples in both Twig and PHP.

asset_id

Filters assets by their Mux asset ID.

twig
{# Get assets by specific asset ID #}
{% set assets = craft.muxAssets.asset_id('abc123').all() %}

{# Get assets by multiple asset IDs #}
{% set assets = craft.muxAssets.asset_id(['abc123', 'def456']).all() %}

{# Exclude specific asset ID #}
{% set assets = craft.muxAssets.asset_id('not abc123').all() %}
php
// Get assets by specific asset ID
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->asset_id('abc123')
    ->all();

// Get assets by multiple asset IDs
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->asset_id(['abc123', 'def456'])
    ->all();

// Exclude specific asset ID
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->asset_id('not abc123')
    ->all();

asset_status

Filters assets by their processing status.

twig
{# Get ready assets #}
{% set assets = craft.muxAssets.asset_status('ready').all() %}

{# Get assets with multiple statuses #}
{% set assets = craft.muxAssets.asset_status(['ready', 'preparing']).all() %}

{# Exclude failed assets #}
{% set assets = craft.muxAssets.asset_status('not failed').all() %}
php
// Get ready assets
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->asset_status('ready')
    ->all();

// Get assets with multiple statuses
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->asset_status(['ready', 'preparing'])
    ->all();

// Exclude failed assets
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->asset_status('not failed')
    ->all();

aspect_ratio

Filters assets by their aspect ratio.

twig
{# Get 16:9 aspect ratio assets #}
{% set assets = craft.muxAssets.aspect_ratio('16:9').all() %}

{# Get multiple aspect ratios #}
{% set assets = craft.muxAssets.aspect_ratio(['16:9', '4:3']).all() %}

{# Exclude square videos #}
{% set assets = craft.muxAssets.aspect_ratio('not 1:1').all() %}
php
// Get 16:9 aspect ratio assets
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->aspect_ratio('16:9')
    ->all();

// Get multiple aspect ratios
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->aspect_ratio(['16:9', '4:3'])
    ->all();

// Exclude square videos
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->aspect_ratio('not 1:1')
    ->all();

duration

Filters assets by their duration in seconds.

twig
{# Get assets longer than 60 seconds #}
{% set assets = craft.muxAssets.duration('> 60').all() %}

{# Get assets between 30 and 120 seconds #}
{% set assets = craft.muxAssets.duration('>= 30, <= 120').all() %}

{# Get specific duration #}
{% set assets = craft.muxAssets.duration(90).all() %}
php
// Get assets longer than 60 seconds
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->duration('> 60')
    ->all();

// Get assets between 30 and 120 seconds
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->duration('>= 30, <= 120')
    ->all();

// Get specific duration
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->duration(90)
    ->all();

is_live

Filters assets by whether they are live streams.

twig
{# Get live stream assets #}
{% set liveAssets = craft.muxAssets.is_live(true).all() %}

{# Get non-live assets #}
{% set videoAssets = craft.muxAssets.is_live(false).all() %}
php
// Get live stream assets
$liveAssets = \rocketpark\mux\elements\MuxAsset::find()
    ->is_live(true)
    ->all();

// Get non-live assets
$videoAssets = \rocketpark\mux\elements\MuxAsset::find()
    ->is_live(false)
    ->all();

Upload and Processing Properties

upload_id

Filters assets by their upload ID.

twig
{# Get assets by upload ID #}
{% set assets = craft.muxAssets.upload_id('upload_123').all() %}

{# Get assets by multiple upload IDs #}
{% set assets = craft.muxAssets.upload_id(['upload_123', 'upload_456']).all() %}
php
// Get assets by upload ID
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->upload_id('upload_123')
    ->all();

// Get assets by multiple upload IDs
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->upload_id(['upload_123', 'upload_456'])
    ->all();

created_at

Filters assets by their creation date.

twig
{# Get assets created today #}
{% set today = now|date('Y-m-d') %}
{% set assets = craft.muxAssets.created_at(today).all() %}

{# Get assets created this week #}
{% set weekStart = now|date_modify('-7 days')|date('Y-m-d') %}
{% set assets = craft.muxAssets.created_at('>= ' ~ weekStart).all() %}
php
// Get assets created today
$today = date('Y-m-d');
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->created_at($today)
    ->all();

// Get assets created this week
$weekStart = date('Y-m-d', strtotime('-7 days'));
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->created_at('>= ' . $weekStart)
    ->all();

ingest_type

Filters assets by their ingest type.

twig
{# Get assets with specific ingest type #}
{% set assets = craft.muxAssets.ingest_type('video').all() %}

{# Get multiple ingest types #}
{% set assets = craft.muxAssets.ingest_type(['video', 'audio']).all() %}
php
// Get assets with specific ingest type
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->ingest_type('video')
    ->all();

// Get multiple ingest types
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->ingest_type(['video', 'audio'])
    ->all();

Playback and Rendition Properties

playback_ids

Filters assets by their playback IDs. Because playback ids are stored as a JSON object in the database, filtering uses the JSON_CONTAINS function. You must provide an exact JSON structure to match against. The JSON_CONTAINS() function checks whether the first JSON document contains the second as a subset.

twig
{# Get assets with specific playback ID #}
{% set params = [
    {
        "id": "M5YbzILsGiW01SARHVQOOZhOuT2mNK64q7Q54JKQAtx5"
    }
] %}
{% set assets = craft.muxAssets.playback_ids(params).all() %}
php
$params = [
    [
        "id" => "Test5YbzIDsGiW01SARHVQOOZhOuT2mNK64q7Q54JKQAtxA"
    ]
];
// Get assets with specific playback ID
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->playback_ids($params)
    ->all();

$params = [
    [
        "id" => "Test5YbzIDsGiW01SARHVQOOZhOuT2mNK64q7Q54JKQAtxA"
    ],
    [
        "id" => "another-playback-id-here"
    ]
];

// Get assets with multiple playback IDs
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->playback_ids($params)
    ->all();

static_renditions

Filters assets based on their static renditions. Because static renditions are stored as a JSON object in the database, filtering uses the JSON_CONTAINS function. You must provide an exact JSON structure to match against. The JSON_CONTAINS() function checks whether the first JSON document contains the second as a subset.

twig
{# Get assets with specific static rendition #}
{% set rendition = {
        "files": [
            {
                "ext": "mp4",
                "status": "ready"
            }
        ]
} %}
{% set assets = craft.muxAssets.static_renditions(rendition).all() %}
php
// Get assets with specific static rendition
$rendition = (object) [ 
    "files" => [
        "ext" => "mp4",
        "status" => "ready"
    ]
];
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->static_renditions($rendition)
    ->all();

Quality and Resolution Properties

max_stored_resolution

Filters assets by their maximum stored resolution.

twig
{# Get 1080p assets #}
{% set assets = craft.muxAssets.max_stored_resolution('1080p').all() %}

{# Get multiple resolutions #}
{% set assets = craft.muxAssets.max_stored_resolution(['1080p', '720p']).all() %}
php
// Get 1080p assets
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->max_stored_resolution('1080p')
    ->all();

// Get multiple resolutions
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->max_stored_resolution(['1080p', '720p'])
    ->all();

max_stored_frame_rate

Filters assets by their maximum stored frame rate.

twig
{# Get 60fps assets #}
{% set assets = craft.muxAssets.max_stored_frame_rate('60').all() %}

{# Get high frame rate assets #}
{% set assets = craft.muxAssets.max_stored_frame_rate('>= 60').all() %}
php
// Get 60fps assets
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->max_stored_frame_rate('60')
    ->all();

// Get high frame rate assets
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->max_stored_frame_rate('>= 60')
    ->all();

resolution_tier

Filters assets by their resolution tier.

twig
{# Get high resolution tier assets #}
{% set assets = craft.muxAssets.resolution_tier('high').all() %}

{# Get multiple resolution tiers #}
{% set assets = craft.muxAssets.resolution_tier(['high', 'medium']).all() %}
php
// Get high resolution tier assets
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->resolution_tier('high')
    ->all();

// Get multiple resolution tiers
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->resolution_tier(['high', 'medium'])
    ->all();

max_resolution_tier

Filters assets by their maximum resolution tier.

twig
{# Get assets with maximum high resolution tier #}
{% set assets = craft.muxAssets.max_resolution_tier('high').all() %}
php
// Get assets with maximum high resolution tier
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->max_resolution_tier('high')
    ->all();

Custom Data Properties

passthrough

Filters assets by their passthrough data.

twig
{# Get assets with specific passthrough data #}
{% set assets = craft.muxAssets.passthrough('user_123').all() %}

{# Get assets with multiple passthrough values #}
{% set assets = craft.muxAssets.passthrough(['user_123', 'user_456']).all() %}
php
// Get assets with specific passthrough data
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->passthrough('user_123')
    ->all();

// Get assets with multiple passthrough values
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->passthrough(['user_123', 'user_456'])
    ->all();

meta

Filters assets by their metadata.

twig
{# Get assets with specific metadata #}
{% set meta = { "title": "My Video", "category": "tutorial" } %}
{% set assets = craft.muxAssets.meta(meta).all() %}
php
// Get assets with specific metadata
$meta = [
    'title' => 'My Video',
    'category' => 'tutorial'
];
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->meta($meta)
    ->all();

errors

Filters assets by their error status.

twig
{# Get assets with errors #}
{% set assets = craft.muxAssets.errors('encoding_failed').all() %}

{# Get assets without errors #}
{% set assets = craft.muxAssets.errors('not encoding_failed').all() %}
php
// Get assets with errors
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->errors('encoding_failed')
    ->all();

// Get assets without errors
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->errors('not encoding_failed')
    ->all();

Track Properties

trackType

Filters assets by their track type.

twig
{# Get assets with video tracks #}
{% set assets = craft.muxAssets.trackType('video').all() %}

{# Get assets with audio tracks #}
{% set assets = craft.muxAssets.trackType('audio').all() %}

{# Get assets with text tracks #}
{% set assets = craft.muxAssets.trackType('text').all() %}
php
// Get assets with video tracks
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->trackType('video')
    ->all();

// Get assets with audio tracks
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->trackType('audio')
    ->all();

// Get assets with text tracks
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->trackType('text')
    ->all();

trackMaxWidth

Filters assets by their track maximum width.

twig
{# Get assets with tracks wider than 1920px #}
{% set assets = craft.muxAssets.trackMaxWidth('> 1920').all() %}

{# Get assets with specific track width #}
{% set assets = craft.muxAssets.trackMaxWidth(1920).all() %}
php
// Get assets with tracks wider than 1920px
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->trackMaxWidth('> 1920')
    ->all();

// Get assets with specific track width
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->trackMaxWidth(1920)
    ->all();

trackMaxHeight

Filters assets by their track maximum height.

twig
{# Get assets with tracks taller than 1080px #}
{% set assets = craft.muxAssets.trackMaxHeight('> 1080').all() %}

{# Get assets with specific track height #}
{% set assets = craft.muxAssets.trackMaxHeight(1080).all() %}
php
// Get assets with tracks taller than 1080px
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->trackMaxHeight('> 1080')
    ->all();

// Get assets with specific track height
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->trackMaxHeight(1080)
    ->all();

trackMaxFrameRate

Filters assets by their track maximum frame rate.

twig
{# Get assets with high frame rate tracks #}
{% set assets = craft.muxAssets.trackMaxFrameRate('>= 60').all() %}

{# Get assets with specific frame rate #}
{% set assets = craft.muxAssets.trackMaxFrameRate(30).all() %}
php
// Get assets with high frame rate tracks
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->trackMaxFrameRate('>= 60')
    ->all();

// Get assets with specific frame rate
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->trackMaxFrameRate(30)
    ->all();

trackDuration

Filters assets by their track duration.

twig
{# Get assets with tracks longer than 60 seconds #}
{% set assets = craft.muxAssets.trackDuration('> 60').all() %}

{# Get assets with specific track duration #}
{% set assets = craft.muxAssets.trackDuration(90).all() %}
php
// Get assets with tracks longer than 60 seconds
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->trackDuration('> 60')
    ->all();

// Get assets with specific track duration
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->trackDuration(90)
    ->all();

trackPrimary

Filters assets by their primary track status.

twig
{# Get assets with primary tracks #}
{% set assets = craft.muxAssets.trackPrimary(true).all() %}

{# Get assets with non-primary tracks #}
{% set assets = craft.muxAssets.trackPrimary(false).all() %}
php
// Get assets with primary tracks
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->trackPrimary(true)
    ->all();

// Get assets with non-primary tracks
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->trackPrimary(false)
    ->all();

trackMaxChannels

Filters assets by their track maximum channels.

twig
{# Get assets with stereo audio tracks #}
{% set assets = craft.muxAssets.trackMaxChannels(2).all() %}

{# Get assets with surround sound tracks #}
{% set assets = craft.muxAssets.trackMaxChannels('>= 6').all() %}
php
// Get assets with stereo audio tracks
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->trackMaxChannels(2)
    ->all();

// Get assets with surround sound tracks
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->trackMaxChannels('>= 6')
    ->all();

trackTextType

Filters assets by their text track type.

twig
{# Get assets with subtitle tracks #}
{% set assets = craft.muxAssets.trackTextType('subtitles').all() %}

{# Get assets with caption tracks #}
{% set assets = craft.muxAssets.trackTextType('captions').all() %}
php
// Get assets with subtitle tracks
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->trackTextType('subtitles')
    ->all();

// Get assets with caption tracks
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->trackTextType('captions')
    ->all();

trackTextSource

Filters assets by their text track source.

twig
{# Get assets with auto-generated text tracks #}
{% set assets = craft.muxAssets.trackTextSource('auto').all() %}

{# Get assets with uploaded text tracks #}
{% set assets = craft.muxAssets.trackTextSource('upload').all() %}
php
// Get assets with auto-generated text tracks
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->trackTextSource('auto')
    ->all();

// Get assets with uploaded text tracks
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->trackTextSource('upload')
    ->all();

trackStatus

Filters assets by their track status.

twig
{# Get assets with ready tracks #}
{% set assets = craft.muxAssets.trackStatus('ready').all() %}

{# Get assets with preparing tracks #}
{% set assets = craft.muxAssets.trackStatus('preparing').all() %}
php
// Get assets with ready tracks
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->trackStatus('ready')
    ->all();
// Get assets with preparing tracks
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->trackStatus('preparing')
    ->all();

trackName

Filters assets by their track name.

twig
{# Get assets with specific track name #}
{% set assets = craft.muxAssets.trackName('English Subtitles').all() %}

{# Get assets with multiple track names #}
{% set assets = craft.muxAssets.trackName(['English Subtitles', 'Spanish Subtitles']).all() %}
php
// Get assets with specific track name
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->trackName('English Subtitles')
    ->all();

// Get assets with multiple track names
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->trackName(['English Subtitles', 'Spanish Subtitles'])
    ->all();

trackLanguageCode

Filters assets by their track language code.

twig
{# Get assets with English tracks #}
{% set assets = craft.muxAssets.trackLanguageCode('en').all() %}

{# Get assets with multiple language tracks #}
{% set assets = craft.muxAssets.trackLanguageCode(['en', 'es', 'fr']).all() %}
php
// Get assets with English tracks
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->trackLanguageCode('en')
    ->all();

// Get assets with multiple language tracks
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->trackLanguageCode(['en', 'es', 'fr'])
    ->all();

trackId

Filters assets by their track ID.

twig
{# Get assets with specific track ID #}
{% set assets = craft.muxAssets.trackId('track_123').all() %}

{# Get assets with multiple track IDs #}
{% set assets = craft.muxAssets.trackId(['track_123', 'track_456']).all() %}
php
// Get assets with specific track ID
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->trackId('track_123')
    ->all();

// Get assets with multiple track IDs
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->trackId(['track_123', 'track_456'])
    ->all();

Metadata Properties

metaTitle

Filters assets by their metadata title.

twig
{# Get assets with specific title #}
{% set assets = craft.muxAssets.metaTitle('My Video Title').all() %}

{# Get assets with multiple titles #}
{% set assets = craft.muxAssets.metaTitle(['Title 1', 'Title 2']).all() %}
php
// Get assets with specific title
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->metaTitle('My Video Title')
    ->all();

// Get assets with multiple titles
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->metaTitle(['Title 1', 'Title 2'])
    ->all();

metaExternalId

Filters assets by their metadata external ID.

twig
{# Get assets with specific external ID #}
{% set assets = craft.muxAssets.metaExternalId('ext_123').all() %}

{# Get assets with multiple external IDs #}
{% set assets = craft.muxAssets.metaExternalId(['ext_123', 'ext_456']).all() %}
php
// Get assets with specific external ID
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->metaExternalId('ext_123')
    ->all();

// Get assets with multiple external IDs
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->metaExternalId(['ext_123', 'ext_456'])
    ->all();

metaCreatorId

Filters assets by their metadata creator ID.

twig
{# Get assets by specific creator #}
{% set assets = craft.muxAssets.metaCreatorId('creator_123').all() %}

{# Get assets by multiple creators #}
{% set assets = craft.muxAssets.metaCreatorId(['creator_123', 'creator_456']).all() %}
php
// Get assets by specific creator
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->metaCreatorId('creator_123')
    ->all();

// Get assets by multiple creators
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->metaCreatorId(['creator_123', 'creator_456'])
    ->all();

Folder and Volume Properties

folderId

Filters assets by their folder ID.

twig
{# Get assets in specific folder #}
{% set assets = craft.muxAssets.folderId(1).all() %}

{# Get assets in multiple folders #}
{% set assets = craft.muxAssets.folderId([1, 2, 3]).all() %}

{# Exclude specific folder #}
{% set assets = craft.muxAssets.folderId('not 1').all() %}
php
// Get assets in specific folder
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->folderId(1)
    ->all();

// Get assets in multiple folders
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->folderId([1, 2, 3])
    ->all();

// Exclude specific folder
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->folderId('not 1')
    ->all();

includeSubfolders

Includes assets from subfolders when using folderId.

twig
{# Get assets in folder and its subfolders #}
{% set assets = craft.muxAssets.folderId(1).includeSubfolders().all() %}

{# Disable subfolder inclusion #}
{% set assets = craft.muxAssets.folderId(1).includeSubfolders(false).all() %}
php
// Get assets in folder and its subfolders
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->folderId(1)
    ->includeSubfolders()
    ->all();

// Disable subfolder inclusion
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->folderId(1)
    ->includeSubfolders(false)
    ->all();

folderPath

Filters assets by their folder path.

twig
{# Get assets in specific folder path #}
{% set assets = craft.muxAssets.folderPath('videos/').all() %}

{# Get assets in folder and subfolders #}
{% set assets = craft.muxAssets.folderPath('videos/*').all() %}

{# Exclude specific folder path #}
{% set assets = craft.muxAssets.folderPath('not videos/*').all() %}
php
// Get assets in specific folder path
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->folderPath('videos/')
    ->all();

// Get assets in folder and subfolders
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->folderPath('videos/*')
    ->all();

// Exclude specific folder path
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->folderPath('not videos/*')
    ->all();

volumeId

Filters assets by their volume ID.

twig
{# Get assets in specific volume #}
{% set assets = craft.muxAssets.volumeId(1).all() %}

{# Get assets in multiple volumes #}
{% set assets = craft.muxAssets.volumeId([1, 2]).all() %}

{# Exclude specific volume #}
{% set assets = craft.muxAssets.volumeId('not 1').all() %}
php
// Get assets in specific volume
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->volumeId(1)
    ->all();

// Get assets in multiple volumes
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->volumeId([1, 2])
    ->all();

// Exclude specific volume
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->volumeId('not 1')
    ->all();

Standard Element Query Methods

Mux assets also support all standard Craft CMS ElementQuery methods:

id

Finds asset based on element id

twig
{# Get by single id #}
{% set assets = craft.muxAssets.id(7).all() %}

{# Get by multiple ids #}
{% set assets = craft.muxAssets.asset_status('ready').id([1,2,3,4,5]).all() %}
php
// Get by single id
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->id(7)
    ->all();

// Get by multiple ids
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->asset_status('ready')
    ->limit([1,2,3,4,5])
    ->all();

offset

limit

Limits the number of results.

twig
{# Get first 10 assets #}
{% set assets = craft.muxAssets.limit(10).all() %}

{# Get first 5 ready assets #}
{% set assets = craft.muxAssets.asset_status('ready').limit(5).all() %}
php
// Get first 10 assets
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->limit(10)
    ->all();

// Get first 5 ready assets
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->asset_status('ready')
    ->limit(5)
    ->all();

offset

Offsets the results.

twig
{# Get assets starting from the 11th result #}
{% set assets = craft.muxAssets.offset(10).all() %}

{# Get next 10 assets after the first 10 #}
{% set assets = craft.muxAssets.limit(10).offset(10).all() %}
php
// Get assets starting from the 11th result
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->offset(10)
    ->all();

// Get next 10 assets after the first 10
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->limit(10)
    ->offset(10)
    ->all();

orderBy

Orders the results.

twig
{# Order by creation date (newest first) #}
{% set assets = craft.muxAssets.orderBy('created_at DESC').all() %}

{# Order by duration (longest first) #}
{% set assets = craft.muxAssets.orderBy('duration DESC').all() %}

{# Order by multiple fields #}
{% set assets = craft.muxAssets.orderBy('asset_status ASC, created_at DESC').all() %}
php
// Order by creation date (newest first)
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->orderBy('created_at DESC')
    ->all();

// Order by duration (longest first)
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->orderBy('duration DESC')
    ->all();

// Order by multiple fields
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->orderBy('asset_status ASC, created_at DESC')
    ->all();

Complex Query Examples

Combining Multiple Filters

twig
{# Get ready 1080p videos longer than 60 seconds #}
{% set assets = craft.muxAssets
    .asset_status('ready')
    .max_stored_resolution('1080p')
    .duration('> 60')
    .is_live(false)
    .orderBy('created_at DESC')
    .limit(20)
    .all() %}

{# Get live streams with English subtitles #}
{% set assets = craft.muxAssets
    .is_live(true)
    .trackLanguageCode('en')
    .trackTextType('subtitles')
    .all() %}
php
// Get ready 1080p videos longer than 60 seconds
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->asset_status('ready')
    ->max_stored_resolution('1080p')
    ->duration('> 60')
    ->is_live(false)
    ->orderBy('created_at DESC')
    ->limit(20)
    ->all();

// Get live streams with English subtitles
$assets = \rocketpark\mux\elements\MuxAsset::find()
    ->is_live(true)
    ->trackLanguageCode('en')
    ->trackTextType('subtitles')
    ->all();