Witajcie, zastanawiam się nad sposobem podpięcia lightboxa pod zdjęcia wgrane poprzez edytor, za wrzucanie zdjęć odpowiedzialny jest skrypt dostarczany przez tinymce

  1. <?php
  2. header("Access-Control-Allow-Origin: *");
  3. $accepted_origins = array();
  4. $imageFolder = "upload/";
  5. reset ($_FILES);
  6. $temp = current($_FILES);
  7. if (is_uploaded_file($temp['tmp_name'])){
  8. if (isset($_SERVER['HTTP_ORIGIN'])) {
  9. if (in_array($_SERVER['HTTP_ORIGIN'], $accepted_origins)) {
  10. header('Access-Control-Allow-Origin: ' . $_SERVER['HTTP_ORIGIN']);
  11. } else {
  12. header("HTTP/1.0 403 Origin Denied");
  13. return;
  14. }
  15. }
  16.  
  17. // header('Access-Control-Allow-Credentials: true');
  18. // header('P3P: CP="There is no P3P policy."');
  19.  
  20. // Sanitize input
  21. if (preg_match("/([^\w\s\d\-_~,;:\[\]\(\).])|([\.]{2,})/", $temp['name'])) {
  22. header("HTTP/1.0 500 Invalid file name.");
  23. return;
  24. }
  25.  
  26. // Verify extension
  27. if (!in_array(strtolower(pathinfo($temp['name'], PATHINFO_EXTENSION)), array("gif", "jpg", "png"))) {
  28. header("HTTP/1.0 500 Invalid extension.");
  29. return;
  30. }
  31.  
  32. // Accept upload if there was no origin, or if it is an accepted origin
  33. $filetowrite = $imageFolder . $temp['name'];
  34. move_uploaded_file($temp['tmp_name'], $filetowrite);
  35.  
  36. // Respond to the successful upload with JSON.
  37. // Use a location key to specify the path to the saved image resource.
  38. echo json_encode(array('location' => $filetowrite));
  39. } else {
  40. // Notify editor that the upload failed
  41. header("HTTP/1.0 500 Server Error");
  42. }
  43. ?>


I zastanawiam się czy jest możliwość aby zdjęcia te zamykały się w linku i klasie potrzebnej do otwierania ich w lightboxie, ogólnie chciałbym stworzyć taką mini galerię z tych zdjęć.
Czy to w ogóle rozsądne rozwiązanie czy lepiej oddzielić edytor od wrzucania zdjęć? Dodam jeszcze że wykorzystuję to do dodawania posta na bloga.