Image size in questions

Image size in questions

par Leon Stringer,
Nombre de réponses : 6
Avatar Core developers Avatar Particularly helpful Moodlers

If I have a quiz question with an image which contains a text element, then in full screen on a PC or laptop it looks fine and the text is readable:

Screenshot of example quiz question showing image containing text, the text is large enough to be read.

If I view this on a smaller screen the image scales (because it's responsive) but now the text in the images becomes difficult to read.

Screenshot of example quiz question showing image containing text, the text is small and difficult to read.

I want to provide a way for learners to read the text. I could set the min-width CSS property to prevent the image getting so small but then the image will get clipped/obscured by borders. I also found this thread on using some non-standard browser features to zoom into the image.

But I wondered if anyone knew of a better way of making images in a quiz visible on smaller screens/devices when the details in the image is part of the question.

Moodle 3.9.11.

Moyenne des évaluations  -
En réponse à Leon Stringer

Re: Image size in questions

par Tim Hunt,
Avatar Core developers Avatar Documentation writers Avatar Particularly helpful Moodlers Avatar Peer reviewers Avatar Plugin developers
Make each sign a separate image, so when the page gets small, they wrap onto more than one row.
Moyenne des évaluations Useful (3)
En réponse à Tim Hunt

Re: Image size in questions

par Leon Stringer,
Avatar Core developers Avatar Particularly helpful Moodlers

Thanks Tim, that's a good idea.

En réponse à Leon Stringer

Re: Image size in questions

par Dominique Bauer,
Avatar Documentation writers Avatar Particularly helpful Moodlers Avatar Plugin developers


The image above is very wide. To see it in full, you have to scroll from left to right. On a desktop computer, this is not a problem. On a small screen, for example that of a smart phone, you can also scroll from left to right, but the entire page may scroll, not just the image.

The code for the image above is as follows:

<img src="imageURL" style="border:12px solid #75623c;">

Below, the same image is enclosed in a div element which allows side scrolling and whose width is adjusted according to that of the window. Thus, on a smart phone, the image can be scrolled inside the screen width, without the rest of the page scrolling sideways.

To appreciate the difference between the scrolling of these two images, view the current page on your phone.



The code for the image above is as follows:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script>
$(document).ready(function() {
    var window_width = window.innerWidth;
    var image_offset = $("#divid").offset();
    responsive_width = window_width - image_offset.left - 30;
    $("#divid").css("max-width", responsive_width);
});
</script>
<div id="divid" style="overflow-x:scroll;border:12px solid #75623c;">
    <img src="imageURL">
</div>

Of course, the border (border:12px solid #75623c;) is not necessary. I put it on just so you can see the difference between the two images.

See the example live at https://moodleformulas.org/course/view.php?id=77§ion=69 ↗.

Moyenne des évaluations Useful (2)
En réponse à Dominique Bauer

Re: Image size in questions

par Dominique Bauer,
Avatar Documentation writers Avatar Particularly helpful Moodlers Avatar Plugin developers

To appreciate the difference between the scrolling of these two images, view the current page on your phone.

should read as:

To appreciate the difference between the scrolling of these two images, view the following page on your phone:

https://moodleformulas.org/course/view.php?id=77&section=69
User name: student
Password: Formulas.1

Moyenne des évaluations Useful (1)
En réponse à Dominique Bauer

Re: Image size in questions

par Dominique Bauer,
Avatar Documentation writers Avatar Particularly helpful Moodlers Avatar Plugin developers

Slicing an image into narrow vertical strip, so when the page gets small, they wrap onto more than one row, may be a workaround in some cases, but it may be inadequate when the image does not lend itself to slicing, such as in the example below:

MoodleForum_202111150826.png?time=1636983263281

The cat is saying: "Don't slice up my portrait, just scroll it. Purrrrr!".

MoodleForum_202111150827.png


See a slightly improved version of the code at https://moodleformulas.org/course/view.php?id=77§ion=69 ↗