Skip to content

Instantly share code, notes, and snippets.

@rossriley
Created September 9, 2015 18:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rossriley/f0c677b79ae43d7dfa96 to your computer and use it in GitHub Desktop.
Save rossriley/f0c677b79ae43d7dfa96 to your computer and use it in GitHub Desktop.
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