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

use Modal Images for controller images #573

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

ellensp
Copy link
Contributor

@ellensp ellensp commented Aug 6, 2024

Add Model images to https://marlinfw.org/docs/hardware/controllers.html

Firstly for the record, I'm not a web developer, I only found out that Model images was a thing today while looking at bootstrap.
Basically I followed https://www.w3schools.com/howto/howto_css_modal_images.asp and https://stackoverflow.com/questions/47798971/several-modal-images-on-page

The current way to view the high resolution images opened up a new browser window. This is rather primitive.
With Modal Images it opens up over the top of the webpage with a close gadget, this is much more intuitive.

As a benefit of using Modal Images the *_thumb.jpg files are no longer required and are generated as needed.

I'm not sure of the best places to add the css and javascript when it comes to jekyll so feel free to move things about.

@thisiskeithb
Copy link
Member

thisiskeithb commented Aug 6, 2024

Modals are fun!

There's an issue with images zooming beyond their actual maximum size and some are blowing beyond the page view:

image



This might be a limitation on the version of Bootstrap we're using, but the only way to exit the modal view is to click the X, when you can normally click anywhere outside of the image/modal content or by pressing escape. See my comment below.

@thisiskeithb
Copy link
Member

thisiskeithb commented Aug 6, 2024

Here's a non-custom image modal example using Bootstrap 5.3, so some variables would likely need to changed to work with 4.x (if it works at all in 4.x 😄):

Click to expand me!

<!DOCTYPE html>
<html lang="en" lang="en" data-bs-theme="dark">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Bootstrap 5 Image Modal</title>
    <link
      href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
      rel="stylesheet"
      integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH"
      crossorigin="anonymous"
    />
  </head>

  <body>
    <div class="container mt-5">
      <h1>Bootstrap 5 Image Modal</h1>
      <!-- <button
        type="button"
        class="btn btn-primary"
        data-bs-toggle="modal"
        data-bs-target="#imgModal"
      >
        Popup image
      </button> -->

      <a href="#" data-bs-toggle="modal" data-bs-target="#imgModal"
        ><img
          src="https://picsum.photos/900/500"
          class="img-thumbnail"
          width="300px"
          alt="Launch image demo modal"
      /></a>

      <div id="imgModal" class="modal fade" tabindex="-1" role="dialog">
        <div class="modal-dialog modal-xl">
          <div class="modal-content">
            <div class="modal-body">
              <img src="https://picsum.photos/900/500" width="100%" />
            </div>
          </div>
        </div>
      </div>
    </div>

    <script
      src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
      integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz"
      crossorigin="anonymous"
    ></script>
  </body>
</html>

Save the contents to a .html file & preview it locally in your browser.

@thinkyhead
Copy link
Member

This particular zoomer is not actually based on Bootstrap. It's set up manually, adding click handlers to the small images and to the modal close box, using a CSS zoom animation on the image and caption. The Bootstrap zoomer should be relatively easy to set up and use, so we could also give that a try and compare.

@ellensp
Copy link
Contributor Author

ellensp commented Aug 7, 2024

Ideally what I would like to see is a way to zoom in to the maximum resolution of the image. But I have no idea how to do that other that writing some custom javascript

@thisiskeithb
Copy link
Member

thisiskeithb commented Aug 7, 2024

This particular zoomer is not actually based on Bootstrap.

I pasted in the Bootstrap example once I realized what was actually going on 😄

Ideally what I would like to see is a way to zoom in to the maximum resolution of the image. But I have no idea how to do that other that writing some custom javascript

Here's a 4.x version:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Bootstrap 4 Image Modal</title>
    <link
      href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
      rel="stylesheet"
      crossorigin="anonymous"
    />
  </head>

  <body>
    <div class="container mt-5">
      <h1>Bootstrap 4 Image Modal</h1>
      <!-- <button
        type="button"
        class="btn btn-primary"
        data-toggle="modal"
        data-target="#imgModal"
      >
        Popup image
      </button> -->

      <a href="#" data-toggle="modal" data-target="#imgModal"
        ><img
          src="https://picsum.photos/900/500"
          class="img-thumbnail"
          width="300px"
          alt="Launch Image Modal"
      /></a>

      <div id="imgModal" class="modal fade" tabindex="-1" role="dialog">
        <div class="modal-dialog modal-xl">
          <div class="modal-content">
            <div class="modal-body">
              <img src="https://picsum.photos/900/500" width="100%" />
            </div>
          </div>
        </div>
      </div>
    </div>
    <script
      src="https://code.jquery.com/jquery-2.2.1.min.js"
      crossorigin="anonymous"
    ></script>
    <script
      src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
      crossorigin="anonymous"
    ></script>
  </body>
</html>

Edit: We're using 3.x, not 4.x 🙃

* Bootstrap v3.3.6 (http://getbootstrap.com)

@thisiskeithb
Copy link
Member

thisiskeithb commented Aug 7, 2024

Looks like Bootstrap 3.3.6 works fine:

Expand me!

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Bootstrap 3 Image Modal</title>
    <link
      href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
      rel="stylesheet"
      crossorigin="anonymous"
    />
  </head>

  <body>
    <div class="container mt-5">
      <h1>Bootstrap 3 Image Modal</h1>
      <!-- <button
        type="button"
        class="btn btn-primary"
        data-toggle="modal"
        data-target="#imgModal"
      >
        Launch Image Modal
      </button> -->

      <a href="#" data-toggle="modal" data-target="#imgModal"
        ><img
          src="https://picsum.photos/900/500"
          class="img-thumbnail"
          width="300px"
          alt="Launch Image Modal"
      /></a>

      <div id="imgModal" class="modal fade" tabindex="-1" role="dialog">
        <div class="modal-dialog modal-lg">
          <div class="modal-content">
            <div class="modal-body">
              <img src="https://picsum.photos/900/500" width="100%" />
            </div>
          </div>
        </div>
      </div>
    </div>
    <script
      src="https://code.jquery.com/jquery-2.2.1.min.js"
      crossorigin="anonymous"
    ></script>
    <script
      src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"
      crossorigin="anonymous"
    ></script>
  </body>
</html>

I had to switch CDNs for the minified Bootstrap JS since jsdelivr didn't have it, but you get the idea.

Bootstrap 3.x also supports thumbnails, so we can do all this with stock Bootstrap.

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

Successfully merging this pull request may close these issues.

3 participants