image.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. require_once("user.php");
  3. $image_url = $_GET['img'];
  4. $image_height = $_GET['height'];
  5. $image_width = $_GET['width'];
  6. $image_source = $_GET['source'];
  7. switch ($image_source) {
  8. case 'emby':
  9. $urlCheck = stripos(EMBYURL, "http");
  10. if ($urlCheck === false) {
  11. $embyAddress = "http://" . EMBYURL;
  12. } else {
  13. $embyAddress = EMBYURL;
  14. }
  15. if(PLEXPORT !== ""){ $embyAddress .= ":" . EMBYPORT; }
  16. if(isset($image_url) && isset($image_height) && isset($image_width)) {
  17. $image_src = $embyAddress . '/Items/'.$image_url.'/Images/Primary?maxHeight='.$image_height.'&maxWidth='.$image_width;
  18. header('Content-type: image/jpeg');
  19. readfile($image_src);
  20. } else {
  21. echo "Invalid Emby Request";
  22. }
  23. break;
  24. default:
  25. $urlCheck = stripos(PLEXURL, "http");
  26. if ($urlCheck === false) {
  27. $plexAddress = "http://" . PLEXURL;
  28. } else {
  29. $plexAddress = PLEXURL;
  30. }
  31. if(PLEXPORT !== ""){ $plexAddress = $plexAddress . ":" . PLEXPORT; }
  32. if(isset($image_url) && isset($image_height) && isset($image_width)) {
  33. $image_src = $plexAddress . '/photo/:/transcode?height='.$image_height.'&width='.$image_width.'&upscale=1&url=' . $image_url . '&X-Plex-Token=' . PLEXTOKEN;
  34. header('Content-type: image/jpeg');
  35. readfile($image_src);
  36. } else {
  37. echo "Invalid Plex Request";
  38. }
  39. break;
  40. }