[enh] yay, handle thumbnails in pictures-group

This commit is contained in:
Laurent Peuch 2015-12-09 07:05:48 +01:00
parent 89399375a4
commit 09c2f2570b
2 changed files with 11 additions and 1 deletions

View File

@ -22,6 +22,16 @@ class TemplateFunctions():
print os.path.join(self.base_dir, image), "->", os.path.join(self.target_dir, image) print os.path.join(self.base_dir, image), "->", os.path.join(self.target_dir, image)
return "" return ""
def generate_thumbnail(self, image, gm_geometry):
thumbnail_name = image.split(".")
thumbnail_name[-2] += "-small"
thumbnail_name = ".".join(thumbnail_name)
command = "gm convert %s -resize %s %s" % (os.path.join(self.base_dir, image), gm_geometry, os.path.join(self.target_dir, thumbnail_name))
print command
os.system(command)
return thumbnail_name
def error(test, error_message): def error(test, error_message):
if test: if test:

View File

@ -5,7 +5,7 @@
{{ helpers.copy_image(image) }} {{ helpers.copy_image(image) }}
<div class="picture"> <div class="picture">
<a href="{{ image }}"> <a href="{{ image }}">
<img src="{{ image }}"> <img src="{{ helpers.generate_thumbnail(image, "x400") }}">
</a> </a>
</div> </div>
{% if not loop.last %} {% if not loop.last %}