Removing alt text when hovering over images (SugarCube)

Twine Version: 2.3.5
Story Format: SugarCube 2.30.0
Browser: Chrome 79.0.3945.123

I noticed that when I use the SugarCube image syntax, the alt text displays the actual code from my passage when I hover over it. This looks very strange especially when an image is a clickable link to another passage. Like this:

[img[http://www.pngall.com/wp-content/uploads/2016/05/Click-Here-PNG-Picture.png][Next]]

The entire line of text above is displayed when I hover over the image in my Chrome browser.

I ended up adding the following code to my StoryInit passage, but just wanted to check to make sure this is the best way to remove this.

<<script>>
jQuery(window).on("load", function(){
	jQuery('#wrap_all a').removeAttr('title');
	jQuery('#wrap_all img').removeAttr('title');
});
<</script>>

Thanks!

That sounds like you have the game running in test mode. Are you using the “Test” button when running your game? If so, remove that code and run the game using the “Play” button and the title text should not appear.

Also, no, that’s not how you’d want to go about editing element attributes with JQuery. You’d want to hook into one of SugarCube’s task objects or passage events. I don’t believe that will be needed here though.

By default, the image markup creates no alt-text/tooltip unless you specify one.

In particular, if you’re seeing the source of the image markup when you hover over the image, then, as Chapel surmised, that’s the debug view for the image, which only appears in Test mode. It will not appear when using the “normal” testing mode Play or via Publish.

Yes, that was it. I didn’t realize that clicking the play icon directly on the passage ran it in test mode. I can see now that the tooltip says as much. Thanks for the clarification.