> excellent question. is there something like a thumbnail plugin in one
> of the several repositiories?
I plan to make one. I also would like to be able to incorporate some
gallery on top of this. Something like:
{% site.gallery('blah/*.jpg') %}
Hope to do this this week but any idea on the best way to do is welcome!
--
Don't use conditional branches as a substitute for a logical expression.
- The Elements of Programming Style (Kernighan & Plauger)
I think its important to allow to specify exact width, height for individual
thumbnail, like
{% site.thumbnail('pic.jpg', 100, 200) %}
and if not specified, take defaults from meta plugin
--
Grygoriy Fuchedzhy
There is a thumbnail implementation right here that can be ported pretty much as is:
https://github.com/lakshmivyas/hyde/blob/master/hydeengine/media_processors.py#L264-287
Thanks
Lakshmi
> --
> You received this message because you are subscribed to the Google Groups "Hyde" group.
> To post to this group, send email to hyde...@googlegroups.com.
> To unsubscribe from this group, send email to hyde-dev+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/hyde-dev?hl=en.
>
> There is a thumbnail implementation right here that can be ported pretty much as is:
> https://github.com/lakshmivyas/hyde/blob/master/hydeengine/media_processors.py#L264-287
I think that thumbnails should be added to the list of resources to be
processed later by other plugins. Since this would be resources that do
not exist in content path (only in deploy path), do you think this could
cause problem?
--
Make sure comments and code agree.
Since they are generated files it is better for them not to be in the list of resources.
If there is additional processing required, the thumbnail plugin should provide options for them.
The only additional processing I can think of is compression. But compression should be included by
default in thumbnail generation I think.
=======
If there definitely is a need for them to be added to the list of resources, they should be generated inside the source
area in `begin_site` event - in that case they can be safely added to the list of resources.
HTH
Lakshmi
> Since they are generated files it is better for them not to be in the
> list of resources.
> If there is additional processing required, the thumbnail plugin
> should provide options for them.
> The only additional processing I can think of is compression. But
> compression should be included by default in thumbnail generation I
> think.
I was thinking about image sizer plugin but the thumbnail plugin could
directly provide height and width.
--
BOFH excuse #170:
popper unable to process jumbo kernel
>> I think that thumbnails should be added to the list of resources to be
>> processed later by other plugins
> Since they are generated files it is better for them not to be in the
> list of resources.
Well, I have done something.
https://github.com/vincentbernat/hyde/tree/thumbnail-plugin
https://github.com/vincentbernat/hyde/commit/478a783274546a7c95cc6a653116ad2d9c4b38dd
I was a bit lost when I wrote this. I wanted to return some kind of
resource and to be able to make it depends on the original resource to
allow it to be regenerated if the original changed. I also find the way
to write the thumb into its target directory a bit hacky. Moreover, it
does not check if a thumbnail exists before retrying to create
one. Again, a resource would do the work for me.
I use it like this:
{% macro gallery(directory) %}
<div class="gallery">
{% for image in site.content.walk_resources()
if image.source_file.kind in ("jpg","png") and
(image.name.startswith(directory) or image.source_file.parent.name == directory) %}
{% set thumb = image.thumb(height=150) %}
<a href="/{{ image.get_relative_deploy_path() }}"><img src="/{{ thumb }}" height="{{ thumb.height }}" width="{{ thumb.width }}"></a>
{% endfor %}
</div>
{% endmacro %}
And this is again something that I don't like. I would like to pass
everything in media_url function but I did not succeed in getting the
paths right...
I have not quite finished my example of use. I will post it when it is done.
--
Vincent Bernat ☯ http://www.luffy.cx
Each module should do one thing well.
>>> I think that thumbnails should be added to the list of resources to be
>>> processed later by other plugins
>> Since they are generated files it is better for them not to be in the
>> list of resources.
> Well, I have done something.
> https://github.com/vincentbernat/hyde/tree/thumbnail-plugin
> https://github.com/vincentbernat/hyde/commit/478a783274546a7c95cc6a653116ad2d9c4b38dd
Here is an example of use:
http://www.luffy.cx/en/blog/2011-thinkpad-edge-11.html
https://github.com/vincentbernat/www.luffy.cx/tree/master/content/en/blog/2011-thinkpad-edge-11.html
--
Vincent Bernat ☯ http://www.luffy.cx
Write clearly - don't be too clever.
> How about this:
So, all images will be thumbnailed?
--
Vincent Bernat ☯ http://www.luffy.cx
panic("CPU too expensive - making holiday in the ANDES!");
2.2.16 /usr/src/linux/arch/mips/kernel/traps.c
Example:
=======
In site.yaml:
thumbnail:
include:
- 'media/images/gallery/*.png'
- 'media/images/gallery/*.jpg'
- 'media/images/slideshow/*.png'
other_settings:
-...
or using meta data:
meta.yaml:
thumbnails:
generate: true
include:
- *.png
Thanks
Lakshmi
> Only the ones that are configured for thumbnailing .
OK. What is the best way to add a file as a new resource?
> Example:
> =======
> In site.yaml:
> or using meta data:
> meta.yaml:
> Thanks
> Lakshmi
Don't over-comment.
site.content.add_resource(File(path))
I've looked into thumbnails plugin written by Vincent Bernat, and rewrote it in
the way you proposed.
Now you can set optional default values for thumbnailing options in site.yaml:
thumbnails:
width: 100
height: 120
prefix: thumb_
And then define actual images to thumbnail using meta plugin, for example in
nodemeta.yaml:
thumbnails:
- width: 50
prefix: thumbs1_
include:
- '*.png'
- '*.jpg'
Notice that thumbnails in the metadata is a list of option sets, this way you
can make thumbnails with different sizes from different images or several
thumbnails from single image, for example:
thumbnails:
- width: 50
prefix: thumbs1_
include:
- '*.png'
- '*.jpg'
- height: 100
prefix: thumbs2_
include:
- '*.png'
- '*.jpg'
which means - make from every picture two thumbnails with different prefixes and
sizes
Can anyone see any issues with this? Should I create pull-request for this?
--
Grygoriy Fuchedzhy
--
Grygoriy Fuchedzhy