image.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 = (isset($_GET['source']) ? $_GET['source'] : 'plex');
  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(EMBYPORT !== ""){ $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. case 'plex':
  25. default:
  26. $urlCheck = stripos(PLEXURL, "http");
  27. if ($urlCheck === false) {
  28. $plexAddress = "http://" . PLEXURL;
  29. } else {
  30. $plexAddress = PLEXURL;
  31. }
  32. if(PLEXPORT !== ""){ $plexAddress = $plexAddress . ":" . PLEXPORT; }
  33. if(isset($image_url) && isset($image_height) && isset($image_width)) {
  34. $image_src = $plexAddress . '/photo/:/transcode?height='.$image_height.'&width='.$image_width.'&upscale=1&url=' . $image_url . '&X-Plex-Token=' . PLEXTOKEN;
  35. header('Content-type: image/jpeg');
  36. readfile($image_src);
  37. } else {
  38. echo "Invalid Plex Request";
  39. }
  40. break;
  41. }