Skip to content
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

Expose variable allow_upscale to settings #1142

Open
discomrade opened this issue Apr 27, 2024 · 2 comments
Open

Expose variable allow_upscale to settings #1142

discomrade opened this issue Apr 27, 2024 · 2 comments
Labels

Comments

@discomrade
Copy link
Contributor

In /ext/media/main.php, the variable allow_upscale determines whether an image is allowed to upscale when thumbnailing (e.g. 64x64 sprite gets enlarged to 192x192). Upscaling images smaller than a thumbnail will almost inevitably result in a visible loss of quality and unnecessary filesize increase, and it's reasonable to want this disabled.

Should it be disabled by default and configurable in the setup page?

@shish shish added the Feature label Jun 7, 2024
@shish
Copy link
Owner

shish commented Jun 7, 2024

Come to think of it I wonder if there's any reason to upscale ever - I can imagine it being useful to have a minimum thumbnail size eg so that people can click on the thumbnail if somebody uploads a 1x1px image; but then I wonder if that could be done via CSS 🤔

@discomrade
Copy link
Contributor Author

discomrade commented Jun 9, 2024

Come to think of it I wonder if there's any reason to upscale ever

I can't think of any reason to upscale.

but then I wonder if that could be done via CSS

I believe it's best done via HTML/CSS.

The simple ways are to make either the <img> or the <a> have a height and width in CSS. But each has a problem:

  • changing the <a> size works, but there's no alt text on hover (shows tags and other information).
  • changing the <img> size (and telling it not to stretch) adds the empty space inside the borders, creating a grid of squares.
    image

To avoid either downside, we can:

  • change the <a> size, and give it title text same as the alt text in the <img>. (/core/basethemelet.php)
  • keep the <img> alt text (it's good for SEO).

The CSS for this is:

.shm-image-list .thumb {
	margin-bottom: 11px; /* I don't know why the 8px needs to become 11px when changing to grid/flex */
	min-height: var(--thumb-height);
	min-width: var(--thumb-width);
	display: grid;
	justify-items: center;
	align-items: center;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants