Skip to content Docs index for AI agents (llms.txt)
Laravel
2.0

Versions

Advanced UsageAssets

Assets

Handling and manipulating Storyblok asset fields in Laravel applications.

Updated by Ric Le Poidevinf2f03b71 min read

Assets are a special type of Field with additional functionality. Where possible to try to detect the type of file upload and return an appropriate Field. Image classes are returned when the file has one of the following extensions: ‘.jpg’, ‘.jpeg’, ‘.png’, ‘.gif’, ‘.webp’. See the Image documentation for more.

Checking for a file

To check if a file has been uploaded in Storyblok call hasFile() on the Asset.

php
$myAsset->hasFile();

Custom asset domains

Storyblok allows you to serve assets from their platform using a custom domain. You will need to define two configuration values in your storyblok config file:

php
[
    // rest of configuration
    `asset_domain` => 'custom.asset.domain',
    `image_service_domain` => 'custom.imageservice.domain'
]

The configuration to customise both domains is needed because:

  • Storyblok links a CloudFront distribution directly to the S3 bucket, bypassing the image service.
  • Non-image assets cannot pass through the image service, so you cannot pass all asset requests through img2.storyblok.com

Thank you to Brent Mullen for this feature!