image_transcoder.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /**
  3. * Copyright (c) UNA, Inc - https://una.io
  4. * MIT License - https://opensource.org/licenses/MIT
  5. *
  6. * @defgroup UnaCore UNA Core
  7. * @{
  8. */
  9. ob_start();
  10. require_once('./inc/header.inc.php');
  11. $sTranscoderObject = bx_process_input(bx_get('o'));
  12. $sHandler = bx_process_input(bx_get('h'));
  13. $oTranscoder = BxDolTranscoderImage::getObjectInstance($sTranscoderObject);
  14. if (!$oTranscoder) {
  15. ob_end_clean();
  16. bx_transcoder_error_occured();
  17. exit;
  18. }
  19. ob_end_clean();
  20. if (isset($_GET['dpx']))
  21. $oTranscoder->forceDevicePixelRatio((int)$_GET['dpx']);
  22. // Video goes through the transcoding queue (getFileUrl queues it), never inline ffmpeg here.
  23. if (!($oTranscoder instanceof BxDolTranscoderVideo) && !$oTranscoder->isFileReady($sHandler) && !$oTranscoder->transcode ($sHandler)) {
  24. bx_transcoder_error_occured();
  25. exit;
  26. }
  27. $sImageUrl = $oTranscoder->getFileUrl($sHandler);
  28. if (!$sImageUrl) {
  29. bx_transcoder_error_occured();
  30. exit;
  31. }
  32. header('Location: ' . $sImageUrl);
  33. exit;
  34. function bx_transcoder_error_occured($sMethod = 'displayPageNotFound')
  35. {
  36. require_once(BX_DIRECTORY_PATH_INC . "design.inc.php");
  37. $oTemplate = BxDolTemplate::getInstance();
  38. $oTemplate->$sMethod ();
  39. }
  40. /** @} */