miniatures pour les groupes
authordj3c1t <dj3c1t@free.fr>
Thu, 15 May 2014 20:53:49 +0000 (22:53 +0200)
committerdj3c1t <dj3c1t@free.fr>
Thu, 15 May 2014 20:53:49 +0000 (22:53 +0200)
app/out/default/views/sources/groupe/list.php
app/out/default/views/sources/groupe/view.php
app/out/default/views/sources/logo_groupe.php

index 97196b2..4d845d4 100644 (file)
     <h4>
       <a href="<?php echo $this->url("sources/groupe/view", array("id" => $id_groupe)) ?>">
         <?php
-
-          $data = $this->data();
-          if
-          (    $groupe["image_uri"]
-            && file_exists($groupe["image_uri"])
-            && ($img_size = $data->img_size($groupe["image_uri"], 120, 100)) !== false
-          ) :
-          $margin_top = floor((100 - $img_size["height"]) / 2);
-
+        
+          $source_image_url = false;
+          $source_thumb = false;
+          $margin_top = 0;
+          if(
+                isset($groupe["image_uri"])
+            &&  $groupe["image_uri"]
+            &&  file_exists($groupe["image_uri"])
+          ){
+            $source_image_url = $groupe["image_uri"];
+            if($data->mw_thumbs_activated()){
+              $source_thumb = $data->img_thumb(
+                $source_image_url,
+                120,
+                100,
+                $this->path("content")."thumbs",
+                array(255, 255, 255)
+              );
+            }
+            else{
+              if($img_size = $data->img_size($source_image_url, 120, 100)){
+                $margin_top = floor((100 - $img_size["height"]) / 2);
+              }
+            }
+            if($source_image_url && !$source_thumb && !$img_size) $source_image_url = false;
+          }
+          if($source_image_url) :
+        
         ?>
-        <img src="<?php echo $this->path("web").$groupe["image_uri"]; ?>"
+
+        <?php if($source_thumb) : ?>
+        <img src="<?php echo $this->path("content")."thumbs/".$source_thumb["thumb_file"] ?>"
+             width="<?php echo $source_thumb["thumb_width"] ?>"
+             height="<?php echo $source_thumb["thumb_height"] ?>"
+             alt="" />
+        <?php else : ?>
+        <img src="<?php echo $this->path("web").$source_image_url; ?>"
              width="<?php echo $img_size["width"] ?>"
              height="<?php echo $img_size["height"] ?>"
              style="margin-top:<?php echo $margin_top ?>px"
              alt="" />
         <?php endif; ?>
+
+        <?php endif; ?>
         <span><?php echo $groupe["nom"] ?></span>
         <br class="clear" />
       </a>
index e272710..e629562 100644 (file)
 <ul class="menu_albums">
 <?php foreach($this->out["albums"]["list"] as $id_album => $album) : ?>
   <li><a href="<?php echo $this->url("sources/album/view", array("album" => $id_album)) ?>" title="<?php echo str_replace("\"", "&quot;", $album["titre"]) ?>">
+    <?php
+    
+      $source_image_url = false;
+      $source_thumb = false;
+      $margin_top = 0;
+      if($album["reference"]){
+        if(
+             isset($album["reference"]["image"])
+          && $album["reference"]["image"]
+        ){
+          $source_image_url = $album["reference"]["image"];
+        }
+      }
+      else{
+        if
+        (    isset($album["image_uri"])
+          && $album["image_uri"]
+          && file_exists($album["image_uri"])
+        ){
+          $source_image_url = $album["image_uri"];
+        }
+      }
+      if($source_image_url){
+        $source_thumb = false;
+        if($data->mw_thumbs_activated()){
+          $source_thumb = $data->img_thumb(
+            $source_image_url,
+            90,
+            90,
+            $this->path("content")."thumbs",
+            array(255, 255, 255)
+          );
+        }
+        else{
+          if($img_size = $data->img_size($source_image_url, 90, 90)){
+            $margin_top = floor((90 - $img_size["height"]) / 2);
+          }
+        }
+        if($source_image_url && !$source_thumb && !$img_size) $source_image_url = false;
+      }
+      if($source_image_url) :
+    
+    ?>
 
-  <?php
-
-    if
-    (    $album["image_uri"]
-      && file_exists($album["image_uri"])
-      && ($img_size = $data->img_size($album["image_uri"], 90, 90)) !== false
-    ) :
-    $margin_top = floor((90 - $img_size["height"]) / 2);
-
-  ?>
-    <img src="<?php echo $this->path("web").$album["image_uri"]; ?>"
+    <?php if($source_thumb) : ?>
+    <img src="<?php echo $this->path("content")."thumbs/".$source_thumb["thumb_file"] ?>"
+         width="<?php echo $source_thumb["thumb_width"] ?>"
+         height="<?php echo $source_thumb["thumb_height"] ?>"
+         alt="" />
+    <?php else : ?>
+    <img src="<?php echo $this->path("web").$source_image_url; ?>"
          width="<?php echo $img_size["width"] ?>"
          height="<?php echo $img_size["height"] ?>"
          style="margin-top:<?php echo $margin_top ?>px"
          alt="" />
-  <?php endif; ?>
-  <span><?php echo $album["titre"] ?></span>
+    <?php endif; ?>
+    <?php endif; ?>
+    <span><?php echo $album["titre"] ?></span>
   </a></li>
 <?php endforeach; ?>
 </ul>
index c46eeb5..3dec41f 100644 (file)
     if(isset($this->out["groupe"])) $groupes = array($this->out["groupe"]["id"] => $this->out["groupe"]);
   }
   foreach($groupes as $groupe) :
-  if(
-        isset($groupe["image_uri"])
-    &&  $groupe["image_uri"]
-    &&  file_exists($groupe["image_uri"])
-    &&  ($img_size = $data->img_size($groupe["image_uri"], 200, 130)) !== false
-  ) :
-  $margin_top = floor((150 - $img_size["height"]) / 2);
+    $source_image_url = false;
+    $source_thumb = false;
+    $margin_top = 0;
+    if(
+          isset($groupe["image_uri"])
+      &&  $groupe["image_uri"]
+      &&  file_exists($groupe["image_uri"])
+    ){
+      $source_image_url = $groupe["image_uri"];
+      if($data->mw_thumbs_activated()){
+        $source_thumb = $data->img_thumb(
+          $source_image_url,
+          200,
+          130,
+          $this->path("content")."thumbs",
+          array(255, 255, 255)
+        );
+      }
+      else{
+        if($img_size = $data->img_size($source_image_url, 200, 130)){
+          $margin_top = floor((130 - $img_size["height"]) / 2);
+        }
+      }
+      if($source_image_url && !$source_thumb && !$img_size) $source_image_url = false;
+    }
+    if($source_image_url) :
 
 ?>
+
 <div class="logo_groupe">
   <a href="<?php echo $this->url("sources/groupe/view", array("id" => $groupe["id"])) ?>">
-    <img src="<?php echo $this->path("web").$groupe["image_uri"]; ?>"
+    <?php if($source_thumb) : ?>
+    <img src="<?php echo $this->path("content")."thumbs/".$source_thumb["thumb_file"] ?>"
+         width="<?php echo $source_thumb["thumb_width"] ?>"
+         height="<?php echo $source_thumb["thumb_height"] ?>"
+         alt="" />
+    <?php else : ?>
+    <img src="<?php echo $this->path("web").$source_image_url; ?>"
          width="<?php echo $img_size["width"] ?>"
          height="<?php echo $img_size["height"] ?>"
          style="margin-top:<?php echo $margin_top ?>px"
          alt="" />
+    <?php endif; ?>
     <span><?php echo $groupe["nom"]; ?></span>
   </a>
 </div>
-<?php endif; ?>
-<?php endforeach; ?>
+
+<?php
+
+    endif;
+  endforeach;
+
+?>
\ No newline at end of file