Display image on honver

Display image on honver

Joel Scott -
回帖数:8

I'm trying to attract attention to a specific hint, thinking that showing an image on mouseOver would be helpful.

I've tried a few generic w3schools suggestions, none of which work (I think that's because I can't have a style element in the Question text?).

Has anybody had any success with this sort of thing or have any suggestions on how one might do this?

I'm not too stressed about what kind of element the mouseOver occurs with (ideally a div).

Any help would be great!

回复Joel Scott

Re: Display image on honver

Rick Jerz -
Particularly helpful Moodlers的头像 Testers的头像
Images typically should have "alt-text." This is a typical accessibility requirement. But there are several factors involved.
1) The software application where you add the image needs to provide the ability to add alt-text.
2) The person adding the image needs to add the alt-text.
3) The browser used to view an image needs to support showing alt-text. Sometimes you need to right-click on the image and "Inspect element".
4) I might be missing some other requirements. Hopefully, someone will correct me if I am wrong, and provide more comments.
回复Joel Scott

Re: Display image on honver

Dominique Bauer -
Documentation writers的头像 Particularly helpful Moodlers的头像 Plugin developers的头像

I think that's because I can't have a style element in the Question text?

In a question text, the Atto and, I think, the TinyMCE editors do not allow the style element, but the Plain text area editor does. Be careful, if you create a style element using the Plain text area, it will be erased as soon as you edit and save the question with the Atto or TinyMCE editor.

For something that applies to the entire site, you can put CSS in Site administration/ Appearance/ Theme / Boost (if you're using the Boost theme) / Advanced settings. You can also put a style element in Site administration/ Appearance/ Addionnal HTML.

You can also create CSS with JavaScript used globally, or in a question text (it will then apply to the current page).

回复Joel Scott

Re: Display image on honver

Dominique Bauer -
Documentation writers的头像 Particularly helpful Moodlers的头像 Plugin developers的头像

Hello Joel,

You can add an image to a Bootstrap tooltip. Here's an example:

MoodleForum_20240621_1448.png

<style>
.tooltip.show {
    opacity: 1;
}
</style>

<p>
    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</p>
<p>
This is a picture of <button type="button" class="btn btn-secondary align-baseline" data-toggle="tooltip" data-html="true" title='<img width="180" src="https://dynamiccourseware.org/draftfile.php/5/user/draft/128559969/20240515_142815_HDR.jpg"><br>Leche de coco'>
  <span style="font-family: Roboto; font-size: 17px;">my younger cat</span>
</button>. Isn't she adorable?
</p>

You can try it at dynamiccourseware.org/additional topics/bootstrap/tooltip with image➚

回复Dominique Bauer

Re: Display image on honver

Joel Scott -
Thanks so much Dominique, that almost nails my problem.

I would love to be able to have the 'target' be a rather than a button (and have the p contain a STACK input box) I think I've modified apprpriately but instead of showing the image that I've selected it just renders a diamond:
image.png
The button there labelled 'Make Lists work' works exactly as you described.
 
<li>
<p data-toggle="tooltip" data-html="true" title='<img width="180" src="https://lms.ntschools.net/pluginfile.php/359028/mod_folder/content/0/thumbnail_thumbnail%20asterisk.png"'>input:ansSorted validation:ansSorted feedback:prtSorted</p>
</li>
回复Joel Scott

Re: Display image on honver

Dominique Bauer -
Documentation writers的头像 Particularly helpful Moodlers的头像 Plugin developers的头像

Hello Joel,

It should work. 微笑

回复Dominique Bauer

Re: Display image on honver

Joel Scott -

Got it!

image.png

<p style="width:75%;" data-toggle="tooltip" data-html="true" title='<img width="180" src="https://lms.ntschools.net/pluginfile.php/359028/mod_folder/content/0/List%20of%20Numbers%20Tooltip.png"><br><div>Use commas to separate the numbers.</div>'>input:ansSorted validation:ansSorted feedback:prtSorted</p>

You're my hero Dominique!

回复Joel Scott

Re: Display image on honver

Dominique Bauer -
Documentation writers的头像 Particularly helpful Moodlers的头像 Plugin developers的头像

In order to display the tooltip above the input box, try using:

<div style="display:inline-block;" data-toggle="tooltip" data-html="true" title='<img width="180" src="https://..."><br>Use commas to separate the numbers.'>input:ansSorted validation:ansSorted feedback:prtSorted</div>