Problem/Motivation

When I upgraded from rc4 to rc5 the initial zoom level sitewide changed from "fit" to 1x, which is way too large in my case. I found the global config for initial zoom level and it only accepts a number, not the strings "fit" or "fill". This leaves me no way (that I'm aware of) to define the initial zoom level to "fit".

Proposed resolution

Change the field type for the initial zoom level config to accept number or string. Or add the ability to define the initial zoom level (with text field) in the views setting for a PhotoSwipe gallery.

Issue fork photoswipe-3414849

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

nickbn created an issue. See original summary.

anybody’s picture

Version: 5.0.0-rc5 » 5.x-dev

Looking at https://photoswipe.com/adjusting-zoom-level/
I totally agree! This should be changed to accept any of the allowed values!

@nickbn could you prepare a MR? I think we should validate the acceptable values then.

anybody’s picture

PS: Default zoom level should be "fit"!

We should reset this regression in an update hook! Thanks for the report!

nickbn’s picture

Version: 5.x-dev » 5.0.0-rc5

@anybody I'm building my first Drupal project in 10 years and I'm a little embarrassed to admit I don't know what an MR is. I'm happy to do anything in my skillset, but my skillset is small (so far). What's an MR?

nickbn’s picture

@anybody also I see you moved this do dev and somehow I accidentally moved it back to rc5. Not my intention, my apologies.

nickbn’s picture

Version: 5.0.0-rc5 » 5.x-dev
anybody’s picture

@nickbn sorry. MR means merge-request. You can do it here as alternative to providing a patch. Do you think you'll be able to give it a try? Or aren't you a developer?

Otherwise we'll have to wait until someone has the time to fix this.

yospyn’s picture

Found same thing as nickbn when I upgraded to rc4 > rc5. So I reverted back to rc4. The images were loading full size with rc5, regardless of the width of the browser window.

anybody’s picture

Status: Active » Needs review

I prepared a MR to fix the issue. Could you please try if it solves the issue for you?

anybody’s picture

Title: Initial zoom level global config only accepts numbers, can't use strings "fit" or "fill" » Regression: Initial zoom level global config only accepts numbers, can't use strings "fit" or "fill"

anybody’s picture

Okay seems to work fine in my tests, let's wait for further feedback.

hephaestus’s picture

Can confirm that is working here.

anybody’s picture

Status: Needs review » Reviewed & tested by the community

Thanks @Hephaestus, so let's set this RTBC!

  • Anybody committed 1250e3b7 on 5.x
    Issue #3414849 by Anybody: Regression: Initial zoom level global config...
anybody’s picture

Status: Reviewed & tested by the community » Fixed

Merged into dev!

I'll tag a new release.

grevil’s picture

Status: Fixed » Needs work

This broke tests. Unfortunately, the new test indicator is quite small. Please adjust the tests accordingly in a follow-up issue and reclose this issue.

grevil’s picture

Status: Needs work » Fixed

Oh wow, it didn't actually.... sorry!!

grevil’s picture

Ok, it did break tests. :P
Furthermore, we are changing the schema definition of "initialZoomLevel", "secondaryZoomLevel" and "maxZoomLevel", but only update the "initialZoomLevel" in our update hook? Does this even work? Will do we not need to cast the other options to string?

And lastly, I don't really like forcing "initialZoomLevel" to be "fit". The original setting should've simply be cast to string, as numbers are valid values as well, see https://photoswipe.com/adjusting-zoom-level/#supported-values.

But we tagged a new release already, so if the module still works all fine! :)

anybody’s picture

@Grevil: The settings are stored in yml anyway, I don't think it's as strict as in databases.

Re "fit": What should be the numeric representation of fit and fill?
The output was miserably broken using the number before, so setting this back to original PS value was urgent.

grevil’s picture

What should be the numeric representation of fit and fill?

There is none, but numeric values are also allowed, so if somebody wanted to have 2x Original Size for the "initialZoomLevel" (value: 2), this update will overwrite this setting with "fit" instead.

And if an allowed value would make the formatter "miserably broken", then we should create an issue in https://github.com/dimsemenov/PhotoSwipe. And disallow numeric strings.

anybody’s picture

Ok perhaps I got you wrong.
If someone enters an invalid value, it's his problem ;D String is fine in this case, as it's what the library accepts and it's JS, not typescript. No need to be over-compliant.

grevil’s picture

But the value is stored in config and configuration is heavily typed. And if we allow both strings like "fit" and numbers like 1 or 2, that should be reflected in the schema definition, where it currently isn't. But there is no way to add multiple schema types for one config entry.

And number are NOT invalid! If that is what you are referring to.

anybody’s picture

"2" == 2 in JavaScript in the end, so I still don't see the problem here. Beside being precise of course, but that's real world vs. perfection. I'm also a fan of perfection! :D

I think I just didn't get the point, we'll talk tomorrow :)

grevil’s picture

Yea, thought the settings form might throw some schema errors or something. But seems all fine! :)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.