Cloud9Developer / Jellyfin-Newsletter-Plugin

GNU General Public License v3.0
67 stars 7 forks source link

[Enhancement] use Jellyfin image parameters when fetching images #64

Open TheDMV2 opened 8 months ago

TheDMV2 commented 8 months ago

In NewsletterDataGenerator.cs

case "JfHosting":
                return $"{config.Hostname}/Items/{item.ItemID}/Images/Primary";

could we add

?fillHeight=200&fillWidth=133&quality=50

to the end to reduce file size being sent dramatically?

In one test, 3.6kb vs 237kb

There is no reason to use giant image files for these thumbnails.

Cloud9Developer commented 8 months ago

I didn't know this was an option lol. Should be a quick add, so should be part of the next release. Will hopefully have some time soon to get some work done on this plugin

TheDMV2 commented 8 months ago

If it helps, this only works for "indirect" images.

Here's a copy-paste from Jellyfin's front page:

<button data-action="link" class="cardImageContainer coveredImage cardContent itemAction lazy blurhashed lazy-image-fadein-fast" aria-label="Project: ALF" style="background-image: url(&quot;https://[MY.SERVER.URL]/Items/097829f6d9fdab9a3f5f29346a1d08fd/Images/Primary?fillHeight=660&amp;fillWidth=440&amp;quality=96&amp;tag=02d446840870e6fedfeede6a6da9309f&quot;);"></button>

This does not work / apply to directly linked images, such as the Jellyfin PNG in the top left corner:

background-image: url(../../assets/img/banner-light.png)

You can't use any "?" directives there.

Rant Honestly, I hate that quality is set to 96 in JF. 115kb vs 32.7kb for Q96 vs Q60. When you have 100 images loading at once, that's a lot of wasted time. And if they set width to 220 (still more than the 187 it is rendering in), it would 11.3kb. 1/10th the data sent. It would help remote users scrolling a lot! But that's not a problem for you, just me venting.

Time to go to forums.jellyfin.org :)

PS. Don't shame me for Project: ALF. I'm a completionist, and it's a movie with Martin Sheen in rare form ranting at ALF while surrounded by a bunch of soldiers who I swear are trying to hold back a chuckle. But you can shame me for being a including ALF. I was wrong. It was not what I remembered.

Cloud9Developer commented 1 month ago

I just had a thought around this.. Why not just add the size you want in your custom HTML? Like:

<img style="width: 133px; height: 200px;" src="{ImageURL}?fillHeight=200&fillWidth=133&quality=50">

would that not work?