Hello,
I know it is outside the scope of this module (since it is not supported JuiceBox functionality) but I thought it would be very useful if it could be implemented into the module.
In JuiceBox, you have to define width AND height in the embedding code. However this can lead to HUGE gaps above/below image when width is 100% and the site is responsive. Using PRO scaling/cropping functions does not make things much better.
It would be nice for example to be able to set width:100% and a fixed aspect ratio and then use JS to calculate the height, as proposed in the JuiceBox forum - set embed code to 100% width, get parent element width, calculate height from width and predefined aspect ratio, re-create JuiceBox instance:
https://juicebox.net/forum/viewtopic.php?pid=7014#p7014
I have used this solution in non-Drupal (pure HTML) JuiceBox instances but my Drupal knowledge does not allow me to implement such code into my site.
P.S.: If it isn't possible (feasible) to add such functionality, I would be very grateful if someone could suggest and quick-and-dirty solution for this problem.
Thank you for your time!
Issue fork juicebox-2858830
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
Comment #2
rjacobs commentedI think this may be something of an edge case feature that's specific to the js library itself. So it may not be something that we want to officially support in the Drupal-side configuration. However, I imagine that there may be some people out there who would be interested in a way to add this functionality within a local theme or module.
I think that the code from the issue link you cited can be used almost as-is. The main difference are that:
new juicebox()part would be omitted.#wrapbut that's somewhat arbitrary and specific to the embed html from their example. In the Drupal case the embed html is built by the module so you just need to check your markup for the right info. If you only have one gallery on the page, and only one gallery type on your site that needs this feature, you can just target the.juicebox-parentwrapper. That wrapper is always used for any gallery of any type created with this module. Alternatively you can be even more specific by targeting a gallery's specific ID or add specificity via a parent selector (like.node-type-article .juicebox-parent)So you might get something like:
I suppose the easiest way to get that js in there would be to do it as part of your theme. See the notes at the link below for more on that (note that you would need to declare the
core/jquerydependency):https://www.drupal.org/docs/8/theming-drupal-8/adding-stylesheets-css-an...
This of course would add the logic to all pages on your site, which would add very small overhead to non-gallery pages. Anyway, it might be the quickest way to get started as test things out. If you need to be more conditional about when the js is added (e.g. only to certain pages with certain galleries) or support the feature on galleries that are generated though some kind of AJAX, then there are other considerations.
Comment #3
rjacobs commentedJust wanted to check if we should leave this open any longer. I'm hoping that the notes from #2 were helpful.
Comment #4
juves commented#2 works great, thank you!
Comment #5
rjacobs commentedGreat, thanks for following-up!
Comment #7
jhmnieuwenhuis commented#2 works fine for me too.
The only thing I notice is that when i change from portrait to landscape and back on my mobile it does not resize.
Any idea what causes that ?
Regards,
Hans
Comment #9
seogow commentedThis solved the problem for me: