anomaly/video-field_type
Anomaly Video Field Type adds a video upload and management field to PyroCMS and Laravel Streams, letting you attach and display video files on entries with minimal configuration.
anomaly/video-field_type is a Streams Platform field type that adds a "video" input to any stream in PyroCMS. It is an addon, not a standalone library — it does nothing until it is installed into a Streams/PyroCMS application and assigned to a stream.
Minimal steps:
composer require anomaly/video-field_type
php artisan addon:install anomaly.video_field_type
Where to look first, in order:
src/VideoFieldType.php — the field type class; shows the slug (anomaly.field_type.video), validation rules, and input/view wiring.src/VideoFieldTypePresenter.php — the developer-facing API you will call from Twig/Blade.resources/views/ — the input and (if present) decorated output views.resources/lang/ — labels/placeholders you will want to override.src/VideoFieldTypeServiceProvider.php — bindings, routes, and any registerable hooks.First use case — add a video field to a stream via a migration/seeder rather than the control panel, so it ships with your module:
use Anomaly\Streams\Platform\Database\Migration\Migration;
class CreateProductsStream extends Migration
{
protected $stream = [
'slug' => 'products',
];
protected $assignments = [
'name' => ['type' => 'anomaly.field_type.text', 'required' => true],
'promo_video' => ['type' => 'anomaly.field_type.video'],
];
}
Then render it in a Twig view:
{% if entry.promo_video.value %}
<h3>Watch the demo</h3>
{{ entry.promo_video.embed|raw }}
{% endif %}
If you are not sure what the presenter offers, run php artisan tinker and dd($entry->promo_video->getPresenter()) or open VideoFieldTypePresenter.php directly — the package is small enough to read end to end in ten minutes.
Assigning the field. Three common routes:
$assignments (above) — preferred because it is reproducible.$stream = Streams::make('products.products');
$stream->addField('promo_video', 'anomaly.field_type.video');
Rendering. Always go through the presenter, not the raw column, so URL parsing/provider detection is applied consistently:
{# Twig #}
{{ entry.promo_video }} {# raw stored value #}
{{ entry.promo_video.embed|raw }} {# embed markup, if supported #}
{{ entry.promo_video.value }} {# underlying value #}
// Blade / PHP
$value = $entry->promo_video->value;
$embed = $entry->promo_video->embed(); // check presenter for exact signature
Forms. In module form builders, reference the type directly so the same input widget is reused:
protected $fields = [
'promo_video' => [
'type' => 'anomaly.field_type.video',
'required' => false,
'instructions' => 'Paste a YouTube or Vimeo link.',
],
];
Validation. Because the field ultimately stores a string, add your own provider-aware rule in the form request or the stream field's rules:
'promo_video' => 'nullable|url',
Extending. Two clean extension points:
VideoFieldType and override getPresenter() / getModifier()).resources/views/input.twig into your addon's resources/views to restyle the widget without touching vendor code.Querying. The value lives in the stream's translated/untranslated table as a normal column. Search, filter, and sort via the repository as you would any string field:
$products = $products->where('promo_video', '!=', null)->get();
"anomaly/video-field_type": "1.*"), and if you rely on it for production, fork it into your own VCS so a Packagist outage or a Laravel constraint bump cannot break installs.composer.json require before upgrading your app.anomaly.field_type.video, not video. A typo in $assignments produces a confusing "field type not found" during migration; the addon must also be installed before the migration runs.$entry->promo_video->embed() on an empty field will often throw or return garbage. Guard with if ($entry->promo_video->value) in Twig/PHP.|raw in Twig; the raw value should not be. If the field only stores a URL, build your own embed in the view rather than trusting presenter output.$assignments or the addon's config, run php artisan cache:clear (and re-run the migration), or the control panel will keep showing the old field.Streams::make('ns.slug')->getAssignment('promo_video')), addon registered (php artisan addon:list), presenter value non-empty, then the view.resources/lang/en/addon.php and field_type.php; override them in your own addon's language files rather than editing vendor files so updates remain safe.vendor/ — Streams addons are re-published on install and your changes will be lost.How can I help you explore Laravel packages today?