]> dev.renevier.net Git - syp.git/blobdiff - inc/utils.php
fixes: wrong url for thumbnails if THUMBSDIRURL is defined
[syp.git] / inc / utils.php
index 12c85c673dfd321a9b1d1a955103aa93f5895d2c..b093b0bae870837ed9d7f64262e27870218d8842 100644 (file)
@@ -45,7 +45,7 @@ function unquote($gpc_str) {
 
 function thumb_url_from_imgpath ($filename) {
     if (defined ("THUMBSDIRURL") && (strlen (THUMBSDIRURL) != 0)) {
-        return rtrim (THUMBSDIRURL, '/') . "/_mini" . rawurlencode ($filename);
+        return rtrim (THUMBSDIRURL, '/') . "/mini_" . rawurlencode ($filename);
     }
     return full_url_from_path (getthumbsdir () . "/mini_" . rawurlencode ($filename));
 }
@@ -101,7 +101,25 @@ function full_url_from_path ($path) {
     return "$proto://$host$port$path";
 }
 
+function create_thumbnail_or_copy ($filename, $destfile) { 
+    try {   
+        $thumbnail_ok = create_thumbnail ($filename, $destfile);
+    } catch (Exception $e) {
+        $thumbnail_ok = false;
+    }
+    if (!$thumbnail_ok) {
+        if (!copy ($filename, $destfile)) {
+            return false; 
+        }
+    }   
+    return true;
+}
+
 function create_thumbnail ($filename, $destfile) {
+    if (!function_exists ("imagecreatefromjpeg")
+        || !function_exists ("imagecreatefrompng")) {
+        return false;
+    }
     $ext = strtolower (ext_safe ($filename));
     if ($ext == "jpg" || $ext == "jpeg") {
         $image = imagecreatefromjpeg ($filename);