/** * get array of thumbnails and info * @param string $upload_path the upload sub path * @param string $type optional thumbnail type eg thumbsm, thumbnail to filter by * @param string $filename optional filename to filter * @param boolean $recurse optional true: recurse into subdirectories * @return array assoc array with thumbnail attributes */ function getThumbnails($upload_path = '', $type = '', $filename = '', $recurse = false) { $thumbs_array = array(); $files = directoryToArray(GSTHUMBNAILPATH . tsl($upload_path), $recurse); foreach ($files as $file) { $split = strpos(basename($file), '.'); $thumbtype = substr(basename($file), 0, $split); $origfile = substr(basename($file), $split + 1); if (!empty($filename) && $filename !== $origfile) { continue; } if (empty($thumbtype) || !empty($type) && $type !== $thumbtype) { continue; } // debugLog('thumbnail ' . $file); $thumb = getimagesize($file); $thumb['width'] = $thumb[0]; unset($thumb[0]); $thumb['height'] = $thumb[1]; unset($thumb[1]); $thumb['type'] = $thumb[2]; unset($thumb[2]); $thumb['attrib'] = $thumb[3]; unset($thumb[3]); $thumb['uploadpath'] = tsl(getRelPath($upload_path, GSTHUMBNAILPATH)); $thumb['primaryfile'] = GSDATAUPLOADPATH . $thumb['uploadpath'] . $origfile; $thumb['filesize'] = filesize($file); $thumb['primaryurl'] = getUploadURI($origfile, $thumb['uploadpath']); $thumb['thumbfile'] = getThumbnailFile(basename($file), $upload_path, ''); $thumb['thumburl'] = getThumbnailURI(basename($file), $upload_path, ''); $thumb['thumbtype'] = $thumbtype; $thumbs_array[$upload_path . basename($file)] = $thumb; } return $thumbs_array; }
// $outfile = null; } // @todo: if needing to save as attachement from post, might need this else second request might be made with post data missing // header('Content-Disposition: Attachment;filename='.$outfile); $image = generate_thumbnail($file, $sub_path, $outfile, $max_x, $max_y, $crop, $image_quality, $show = true, $image_type); if (isset($_REQUEST['debug']) || isset($_REQUEST['json'])) { $output = ob_get_contents(); // get the image as a string in a variable ob_end_clean(); //Turn off output buffering and clean it header("Content-Type: text/json"); // add filesize and base64 encoded image $image->image['bytes'] = strlen($output); // size in bytes $image->imagedata = base64_encode($output); // remove resources and filepaths unset($image->image['src']); unset($image->image['des']); unset($image->image['srcfile']); unset($image->image['outfile']); // $image->image['debuglog'] = strip_tags($GS_DEBUG);; // add url to thumbnail if (isset($image->image['outfile'])) { $image->image['thumb_url'] = getThumbnailURI($outfile, $sub_path, ''); } // echo "<pre>",print_r($image->image,true),"</pre>"; // json encode echo json_encode($image); } exit; /* ?> */