1 <?php
2
3 4 5 6 7 8 9 10
11
12 namespace Icybee\Modules\Images;
13
14 use ICanBoogie\HTTP\Request;
15 use ICanBoogie\Modules\Thumbnailer\Version;
16
17 18 19
20 class ThumbnailOperation extends \ICanBoogie\Modules\Thumbnailer\GetOperation
21 {
22 protected function resolve_version(Request $request)
23 {
24 if (isset($request->path_params['size']))
25 {
26 $version = Version::from_uri($request->uri);
27 }
28 else
29 {
30 $version = parent::resolve_version($request);
31 }
32
33 $version->src = $this->resolve_version_src($request);
34
35 return $version;
36 }
37
38 protected function resolve_version_src(Request $request)
39 {
40 $nid = $request['nid'];
41 $root = \ICanBoogie\DOCUMENT_ROOT;
42 $files = glob(\ICanBoogie\REPOSITORY . "files/*/{$nid}-*");
43
44 if (!$files)
45 {
46 return;
47 }
48
49 return substr(array_shift($files), strlen($root));
50 }
51 }