Skip to content

Instantly share code, notes, and snippets.

@rossriley
Created September 9, 2015 18:25
Add a contenttype / id prefix to an image upload path
<?php
// Appears in your bootstrap file, before the call to $app->run()
$app['upload'] = $app->extend('upload', function ($handler, $app) {
if ($app['request']->get('contenttype') == 'pages') {
if ($app['request']->get('contenttypeslug') && $app['request']->get('id')) {
$handler->setPrefix("/".$app['request']->get('contenttypeslug')."/".$app['request']->get('id'));
}
}
return $handler;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment