Image size in questions

Image size in questions

by Leon Stringer -
Number of replies: 6
Picture of Core developers Picture of 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.

Average of ratings: -
In reply to Leon Stringer

Re: Image size in questions

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Make each sign a separate image, so when the page gets small, they wrap onto more than one row.
Average of ratings: Useful (3)
In reply to Tim Hunt

Re: Image size in questions

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

Thanks Tim, that's a good idea.

In reply to Leon Stringer

Re: Image size in questions

by Dominique Bauer -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of 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 ↗.

Average of ratings: Useful (2)
In reply to Dominique Bauer

Re: Image size in questions

by Dominique Bauer -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of 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

Average of ratings: Useful (1)
In reply to Dominique Bauer

Re: Image size in questions

by Dominique Bauer -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of 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 ↗

In reply to Dominique Bauer

Re: Image size in questions

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

Thanks Dominique, that's a really interesting approach, I'll try it out.