Skip to content

Instantly share code, notes, and snippets.

@bastianallgeier
Created January 26, 2015 14:38
Show Gist options
  • Save bastianallgeier/1e7123c904d480593c7b to your computer and use it in GitHub Desktop.
Save bastianallgeier/1e7123c904d480593c7b to your computer and use it in GitHub Desktop.
Thumbnail destinations with page structure
<?php
c::set('thumbs.destination', function($thumb) {
$page = $thumb->source->page();
$filename = $thumb->source->name() . '-' . $thumb->settingsIdentifier() . '.' . $thumb->source->extension();
$root = $thumb->options['root'] . DS . str_replace('/', DS, $page->uri()) . DS . $filename;
$url = $thumb->options['url'] . '/' . $page->uri() . '/' . $filename;
// create the directory
dir::make(dirname($root));
return new Obj(array(
'url' => $url,
'root' => $root
));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment