saimn / sigal

yet another simple static gallery generator
http://sigal.saimon.org/
MIT License
884 stars 169 forks source link

After file format conversion, thumbnail generation uses the wrong url #476

Open shuhaowu opened 2 years ago

shuhaowu commented 2 years ago

This is a part of series of bugs that I've discovered while making a somewhat complex gallery with sigal.

This issue pertains to image file format conversion and thumbnail url generation. The example can be see in this repo.

In this case, we need to first workaround the problem outlined in #474 by adding the two lines into the plugins:

title = "Test Gallery"
source = "gallery"
theme = "photoswipe"

img_format = "JPEG"
img_size = (3000, 2000)
keep_orig = True

jpg_options = {
  'quality': 90,
  'optimize': True,
  'progressive': True,
}

plugins = [
  "PIL.PngImagePlugin",
  "PIL.JpegImagePlugin",
]

After this workaround is applied, the conversion works. However, if you have a sub album like this:

gallery
└── subgallery
    ├── index.md
    └── Untitled.png

where the index.md file looks like:

Title: Subgallery
Thumbnail: Untitled.png

The album.thumbnail property will be generated incorrectly with a .png extension instead of a .jpeg extensions. After building the above, we can look at the html and the thumbnail folder:

$ cat _build/index.html | grep thumb
    <div class="menu-img thumbnail">
        <img src="subgallery/thumbnails/Untitled.png" class="album_thumb"
$ ls -l _build/subgallery/thumbnails
total 4
-rw-rw-r-- 1 shuhao shuhao 482 Jul 23 17:17 Untitled.jpeg

This obviously results in issues with the generated gallery as the thumbnail for the album is broken. This occurs on all themes.

saimn commented 2 years ago

Not ideal but you should just use the name of the generated thumbnail, ie. Untitled.jpeg.