*/
public function getPhotoPath(string $size = ''): string
{
- $url = '/photo/media/';
- switch ($size) {
- case Proxy::SIZE_MICRO:
- $url .= Proxy::PIXEL_MICRO . '/';
- break;
- case Proxy::SIZE_THUMB:
- $url .= Proxy::PIXEL_THUMB . '/';
- break;
- case Proxy::SIZE_SMALL:
- $url .= Proxy::PIXEL_SMALL . '/';
- break;
- case Proxy::SIZE_MEDIUM:
- $url .= Proxy::PIXEL_MEDIUM . '/';
- break;
- case Proxy::SIZE_LARGE:
- $url .= Proxy::PIXEL_LARGE . '/';
- break;
- }
- return $url . $this->id;
+ return '/photo/media/' .
+ (Proxy::getPixelsFromSize($size) ? Proxy::getPixelsFromSize($size) . '/' : '') .
+ $this->id;
}
/**
*/
public function getPreviewPath(string $size = ''): string
{
- $url = '/photo/preview/';
- switch ($size) {
- case Proxy::SIZE_MICRO:
- $url .= Proxy::PIXEL_MICRO . '/';
- break;
- case Proxy::SIZE_THUMB:
- $url .= Proxy::PIXEL_THUMB . '/';
- break;
- case Proxy::SIZE_SMALL:
- $url .= Proxy::PIXEL_SMALL . '/';
- break;
- case Proxy::SIZE_MEDIUM:
- $url .= Proxy::PIXEL_MEDIUM . '/';
- break;
- case Proxy::SIZE_LARGE:
- $url .= Proxy::PIXEL_LARGE . '/';
- break;
- }
- return $url . $this->id;
+ return '/photo/preview/' .
+ (Proxy::getPixelsFromSize($size) ? Proxy::getPixelsFromSize($size) . '/' : '') .
+ $this->id;
+
}
}
*/
public static function getPreviewUrlForId(int $id, string $size = ''): string
{
- $url = DI::baseUrl() . '/photo/preview/';
- switch ($size) {
- case Proxy::SIZE_MICRO:
- $url .= Proxy::PIXEL_MICRO . '/';
- break;
- case Proxy::SIZE_THUMB:
- $url .= Proxy::PIXEL_THUMB . '/';
- break;
- case Proxy::SIZE_SMALL:
- $url .= Proxy::PIXEL_SMALL . '/';
- break;
- case Proxy::SIZE_MEDIUM:
- $url .= Proxy::PIXEL_MEDIUM . '/';
- break;
- case Proxy::SIZE_LARGE:
- $url .= Proxy::PIXEL_LARGE . '/';
- break;
- }
- return $url . $id;
+ return '/photo/preview/' .
+ (Proxy::getPixelsFromSize($size) ? Proxy::getPixelsFromSize($size) . '/' : '') .
+ $id;
}
/**
*/
public static function getUrlForId(int $id, string $size = ''): string
{
- $url = DI::baseUrl() . '/photo/media/';
- switch ($size) {
- case Proxy::SIZE_MICRO:
- $url .= Proxy::PIXEL_MICRO . '/';
- break;
- case Proxy::SIZE_THUMB:
- $url .= Proxy::PIXEL_THUMB . '/';
- break;
- case Proxy::SIZE_SMALL:
- $url .= Proxy::PIXEL_SMALL . '/';
- break;
- case Proxy::SIZE_MEDIUM:
- $url .= Proxy::PIXEL_MEDIUM . '/';
- break;
- case Proxy::SIZE_LARGE:
- $url .= Proxy::PIXEL_LARGE . '/';
- break;
- }
- return $url . $id;
+ return '/photo/media/' .
+ (Proxy::getPixelsFromSize($size) ? Proxy::getPixelsFromSize($size) . '/' : '') .
+ $id;
}
}
return $matches[1] . self::proxifyUrl(htmlspecialchars_decode($matches[2])) . $matches[3];
}
+ public static function getPixelsFromSize(string $size): int
+ {
+ switch ($size) {
+ case Proxy::SIZE_MICRO:
+ return Proxy::PIXEL_MICRO;
+ case Proxy::SIZE_THUMB:
+ return Proxy::PIXEL_THUMB;
+ case Proxy::SIZE_SMALL:
+ return Proxy::PIXEL_SMALL;
+ case Proxy::SIZE_MEDIUM:
+ return Proxy::PIXEL_MEDIUM;
+ case Proxy::SIZE_LARGE:
+ return Proxy::PIXEL_LARGE;
+ default:
+ return 0;
+ }
+ }
}