Core Concepts
Media Handling
Working with Media for images, videos, and documents.
Media Handling
Media
A single media attachment - image, video, audio, or document.
use OwlStack\Media;
// Quick factory methods
$image = Media::image('/path/to/photo.jpg');
$video = Media::video('/path/to/clip.mp4');
// Full constructor
$image = Media::create(
path: '/path/to/photo.jpg',
mimeType: 'image/jpeg',
altText: 'A sunset over the ocean',
);Type checks
$image->isImage(); // true
$image->isVideo(); // false
$image->isAudio(); // false
$image->isDocument(); // falseMediaCollection
An immutable, typed collection. Adding items returns a new instance.
use OwlStack\MediaCollection;
$collection = new MediaCollection();
$collection = $collection->add($image1);
$collection = $collection->add($image2);
$collection = $collection->add($video);
$collection->count(); // 3
$collection->first(); // $image1
$collection->images(); // MediaCollection with $image1, $image2
$collection->videos(); // MediaCollection with $video
$collection->isEmpty(); // false
$collection->all(); // Media[]Attaching to a Post
use OwlStack\Post;
use OwlStack\Media;
use OwlStack\MediaCollection;
$post = Post::create('Check out these photos!')
->withMediaCollection(new MediaCollection([
Media::image('/path/to/img1.jpg'),
Media::image('/path/to/img2.jpg'),
]));Platform media constraints
Each platform has different media requirements. OwlStack handles validation and processing on the server:
| Platform | Max Media | Supported Types |
|---|---|---|
| Telegram | 10 | JPEG, PNG, GIF, MP4, OGG |
| Twitter/X | 4 | JPEG, PNG, GIF, MP4 |
| 1 | JPEG, PNG, GIF, BMP, MP4, AVI | |
| 1 | JPEG, PNG, GIF | |
| Discord | 10 | JPEG, PNG, GIF, WebP, MP4 |
| 10 | JPEG, MP4 | |
| 1 | JPEG, PNG, GIF, WebP, MP4 | |
| 1 | JPEG, PNG, GIF |
When you publish with media, OwlStack's cloud:
- Validates the file type against the target platform
- Resizes images if they exceed platform limits
- Converts formats as needed (e.g., PNG to JPEG for Instagram)
- Uploads the media to the platform's API