Uses properly resized thumbnails for medals in user's profile.
authorVincent Zanotti <vincent.zanotti@polytechnique.org>
Thu, 29 May 2008 19:00:56 +0000 (21:00 +0200)
committerVincent Zanotti <vincent.zanotti@polytechnique.org>
Thu, 29 May 2008 19:00:56 +0000 (21:00 +0200)
Signed-off-by: Vincent Zanotti <vincent.zanotti@polytechnique.org>
Makefile
htdocs/images/medals/thumb/.gitignore [new file with mode: 0644]
modules/profile.php
templates/profile/deco.medal.tpl
templates/profile/profile.tpl

index 7b62aeb..0b6b37b 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -26,7 +26,7 @@ endef
 
 all: build
 
-build: core banana wiki jquery
+build: core banana wiki medals jquery
 
 q:
        @echo -e "Code statistics\n"
@@ -114,7 +114,16 @@ htdocs/css/banana.css:
 include/banana/banana.inc.php:
        cd $(@D) && find $(BANANA)/banana/ -name '*.php' -exec ln -snf {} . ";"
 
+##
+## Medal thumbnails
+##
+MEDAL_PICTURES=$(wildcard htdocs/images/medals/*.jpg)
+MEDAL_THUMBNAILS=$(subst /medals/,/medals/thumb/,$(MEDAL_PICTURES))
+
+medals: $(MEDAL_THUMBNAILS)
 
+$(MEDAL_THUMBNAILS): $(subst /medals/thumb/,/medals/,$(@F))
+       convert -resize x50 $(subst /medals/thumb/,/medals/,$@) $@
 
 ##
 ## jquery
diff --git a/htdocs/images/medals/thumb/.gitignore b/htdocs/images/medals/thumb/.gitignore
new file mode 100644 (file)
index 0000000..66b83c1
--- /dev/null
@@ -0,0 +1 @@
+/*.jpg
index bde1cf2..c72a9c0 100644 (file)
@@ -105,11 +105,16 @@ class ProfileModule extends PLModule
 
     function handler_medal(&$page, $mid)
     {
+        $thumb = ($mid == 'thumb');
+        $mid = $thumb ? @func_get_arg(2) : $mid;
+
         $res = XDB::query("SELECT  img
                              FROM  profile_medals
                             WHERE  id = {?}",
                           $mid);
-        $img  = dirname(__FILE__).'/../htdocs/images/medals/' . $res->fetchOneCell();
+        $img  = $thumb ?
+            dirname(__FILE__).'/../htdocs/images/medals/thumb/' . $res->fetchOneCell() :
+            dirname(__FILE__).'/../htdocs/images/medals/' . $res->fetchOneCell();
         $type = mime_content_type($img);
         header("Content-Type: $type");
         echo file_get_contents($img);
index 6cf8339..4e76dcf 100644 (file)
@@ -22,7 +22,7 @@
 
 <div id="medal_{$id}" style="clear: both; margin-top: 1em; height: 50px; vertical-align: middle">
   <div style="float: left; margin-right: 0.3em">
-    <img src="profile/medal/{$id}" height="50" />
+    <img src="profile/medal/thumb/{$id}" height="50px" />
   </div>
   <div style="float: left; width: 70%">
     <div><b id="medal_name_{$id}"></b>
index 68ce962..e6a51d2 100644 (file)
@@ -172,7 +172,7 @@ function chgMainWinLoc(strPage)
     <h2>Distinctions&nbsp;: </h2>
     {foreach from=$x.medals item=m}
     <div class="medal_frame">
-      <img src="profile/medal/{$m.id}" width="24" alt="{$m.medal}" title="{$m.medal}" style='float: left;' />
+      <img src="profile/medal/thumb/{$m.id}" height="50px" alt="{$m.medal}" title="{$m.medal}" style='float: left;' />
       <div class="medal_text">
         {$m.medal}<br />{$m.grade}
       </div>