/** * getFileForPhotoWithScale function. * * @access private * @param Models\Photo $photo * @param mixed $scale * @return [$file, $temp, $mtime] */ private static function getFileForPhotoWithScale(Models\Photo $photo, $scale) { $extension = $photo->extension; $bucket = 'other'; $path = ''; if ($scale == 'photo') { if ($photo->get('modified')) { $path = '/' . $photo->get('id') . '_mod.' . $extension; } else { $bucket = 'photo'; $path = rtrim('/' . ltrim($photo->get('path'), '/'), '/') . '/' . $photo->get('filename'); } } elseif ($scale == 'scaled') { $thumbSize = Models\Preferences::valueForModuleWithKey('CameraLife', 'scaledsize'); $path = "/{$photo->get('id')}_{$thumbSize}.{$extension}"; } elseif ($scale == 'thumbnail') { $thumbSize = Models\Preferences::valueForModuleWithKey('CameraLife', 'thumbsize'); $path = "/{$photo->get('id')}_{$thumbSize}.{$extension}"; } elseif (is_numeric($scale)) { $valid = preg_split('/[, ]+/', Models\Preferences::valueForModuleWithKey('CameraLife', 'optionsizes')); if (!in_array($scale, $valid)) { throw new \Exception('This image size has not been allowed'); } $path = "/{$photo->get('id')}_{$scale}.{$extension}"; } else { throw new \Exception('Missing or bad size parameter'); } $fileStore = Models\FileStore::fileStoreWithName($bucket); list($file, $temp, $mtime) = $fileStore->getFile($path); if (!$file) { $photo->generateThumbnail(); list($file, $temp, $mtime) = $fileStore->getFile($path); } return [$file, $temp, $mtime]; }