New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make thumbnail naming configurable with IMAGE_THUMBNAIL_FORMAT. #2565
Make thumbnail naming configurable with IMAGE_THUMBNAIL_FORMAT. #2565
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, and it's useful.
@@ -45,6 +45,7 @@ def set_site(self, site): | |||
|
|||
def process_tree(self, src, dst): | |||
"""Process all images in a src tree and put the (possibly) rescaled images in the dst folder.""" | |||
thumb_fmt = self.kw['image_thumbnail_format'] | |||
ignore = set(['.svn']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really related to this PR but WTF. Also, Thumbs.db special casing a few lines below makes little sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the WTF relate to the plugin's usage of a dictionary for its configuration items (instead of just object attributes) or to my placement of retrieving the thumbnail format?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.svn
is the real WTF. And Thumbs.db
/.DS_Store
special handling below. Pre-existing WTF, that is.
(You don’t need that variable, you could just take it out of self.kw
on line 65; that would actually look better IMO
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I considered that, but I don't like retrieving the same item from a dictionary over and over again during each iteration, that's why I opted for retrieving it once before entering the loop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@blubberdiblub sorry, the WTF is not in your code, it's that preexisting stuff about .svn :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps {name}
would look better than {stem}
though?
Sure, can be argued. I preferred |
You decide. |
Alright, there's no need to contribute to the proliferation of even more terms for the same thing (there are already like 4 or so ;) ) and there's no danger of someone getting it wrong, as far as I can tell, so I'll change it to |
Alright, thanks for contributing to Nikola! 🎉 |
(I added your name to AUTHORS.txt, by the way) |
Thanks for the neat feature @blubberdiblub !!!! |
This will make it possible to deviate from the hard-coded thumbnail naming scheme of
original_image_name.thumbnail.extension
.Coincidentally, it also allows to force all thumbnails to a particular image format (say JPEG) by putting that extension into the template literally instead of using the
{ext}
placeholder.The default template
'{stem}.thumbnail{ext}'
corresponds to the current hard-coded naming scheme, so it's backwards compatible.My personal use case is getting
.jpg
thumbnails out of source.png
images, as my source material mainly consists of paletted 4 and 16 color images, which compress extremely well as PNG images, but when scaled down as thumbnails, they gain all kinds of extra shades of colors due to interpolation (which I want to keep, this is really fine and makes the thumbnails very nice to look at despite their smaller size), so the thumbnail files get significantly larger than the actual images. Considering that the primary blog article (before following the links to the original images) should be lean and mean, this is somewhat disappointing. So generating JPEG thumbnails is my way of counteracting the file size increase somewhat:Also, I don't particularly like the
.thumbnail
string, as it's a bit too long for my taste. Making the naming configurable enables me to change that in my blog'sconf.py
later to whatever I desire.