Problem with images

in Userscripts.org discussion
Subscribe to Problem with images 9 posts, 3 voices



QP Scriptwright

Hi there,

For some reason I can include images in a script description if I include an URL but not if I try to use the "data" images (not sure what to really call it).

Eg.:
WORKS: img tag with src="http://static.userscripts.org/images/userscripts.org.png?1193642338"

FAILS: img tag with
src="data:image/gif,GIF89a%11%00%0F%00%C4%1F%00%04%04%04%02%02%02%0B%0B%0BRRR%0F%0F%0F%08%08%08%40%40%40DDD%FD%FD%FD%FC%FC%FC999%09%09%09%0D%0D%0D%3D%3D%3D333%0C%0C%0COOOKKK%F9%F9%F9%E7%E7%E7GGGHHH%14%14%14%FE%FE%FEXXX%FB%FB%FB%3A%3A%3A666222%FF%FF%FF%00%00%00%FF%FF%FF!%F9%04%01%00%00%1F%00%2C%00%00%00%00%11%00%0F%00%00%05~%E0'%8Edin%117r%83j~%5Cv%ACR%F5~%0A%E3~%D1%B2%93%1C%8E%25%08%E3x%0E%3F%11%A7%E3!l%3E%1B%26%C0P%E2%18%3CXN%83%03%C0Rv%18NB%E0)L%3C%82%04%01%FBx%88%1C%1Ef%00p%5E%20%3C%16OW%A4(t%02kAQXd%00JX%1E%1B%2CE%10%1E%01%01%1E%22%03%08%05C%25%0EL%02%0CJ%7F%1E%0DU%17k%910%1AVI%1C%8A%8A7%AB%1F!%00%3B"

Why would this happen? Can this be fixed?

 
Descriptor Scriptwright

Probably so that people don't abuse server space, it's a highly inefficient method of storing images and consumes about 30% more space than just uploading the image would. That data URI is more than 2X larger than the binocular image itself.

Could be another reason as well, like, it doesn't work in all browsers.

 
QP Scriptwright

Hi there,

Descriptor, yeah I agree that it is inefficient to use this format, though it is great for GM scripts since the image is there and there is no accessing any server (specially in the case of a third party).

As for working in all browsers, I'm not sure if it does, but it does in mine when I made a simple HTML at my PC or even in my script which is working fine, but not in this site so that wouldn't be the problem in this case. In other words, in this case it really seems to be a site specific issue. (btw, I assume you copied the string to somewhere to see that it was a binocular img, cause I can't see it.... please tell me if I'm wrong).

On the other hand, in this case I wouldn't ming putting the image really there but... can I upload the image to be here in the site? I mean I really didn't want to upload it to a third party server, though maybe that's what I should do....

By the way, I also tried another thing that didn't work: using a style tag... it appears as it was text.
For the sake of testing here, I tried this:
<style>
body {
color: purple;
background-color: #d8da3d }
</style>
(taken from http://www.w3.org/Style/Examples/011/firstcss and also tested somewhere else working fine... just not here)

Can someone help me with these little problems? (maybe it is simply lack of HTML / site config / ... knowledge)

 
znerp Scriptwright

I don't know if it helps, I'm not really following what's going on, but I copied the data image into my address bar and the 17x15 binocular image worked fine for me.

 
Descriptor Scriptwright

Well, I think the issue isn't whether the data URI works, I think we know it works. I added it to a GM test script as an image src and appended the node to a page, then I saved the image which is how I know it's a gif file of 257 bytes.

The problem is adding it to a script description (or message post) on this site, which can't be done - I think someone has requested this before.
What I don't understand is how you got this to work somewhere else, you mean you tried it in a forum somewhere? The STYLE tag can only be used inside the HEAD, which is mentioned in that W3C link (see also: edef-STYLE), and it shouldn't have any effect if you just stick it in a message post (which would go inside BODY). However the browser's quirks mode allows strange things to work even if they shouldn't.

This server (from my experience with posting here) only allows a limited set of HTML tags, the other tags are escaped or removed. I assume it doesn't allow data URIs at all, converts them to plain text I imagine. Notice also we can't upload any images, even the avatars are created and stored somewhere else. I don't know the reason for this, security or maybe server load.

I had this same problem on another forum, I wanted a tiny little icon that wasn't in their icon list, and they had no way to upload one. If I had thought to try a data URI I would have, but I wouldn't expect it to work. It's better to just store it elsewhere anyway, there are lots of free image hosts.

The easiest and most reliable way would be to use your own ISP. If you get email from your ISP then they probably give you a little "user web space" like 10MB. That's what I used to do, but I know most people these days aren't even aware they have this option - people can't figure out FTP and noone uses Netscape Composer anymore, so this nifty little feature is fading away (the sad fact is that ISPs just don't bother to explain this anymore). This isn't a real good option if you want to remain anonymous.

I like to use imagevenue when I don't want a link going to my own server. They only allow jpg files though, so for an icon I had to either find it in jpg format or convert it to jpg. If the file is very small, thumbnail size, you can link to it directly, so this works out pretty good. There are plenty of image hosts, I don't know the best one but at least imagevenue has very few ads.

 
znerp Scriptwright

@Descriptor: Apparently I should just keep my nose out, ignore that post then. Incidentally, I've always found photobucket to work well for image hosting; I use it for all the images in my script metadata.

 
QP Scriptwright

Ok, thanks to both.

I guess I'll either simply indicate what it is or I'll have to put it in some other site as you said.

The thing is that I wanted to have everything related to my script... in my script.
If you see the source of my script, you'll even notice that I keep (in comments) the small and the large descriptions, that way I update all at once and then I only have to copy that part to the appropriate descriptions and the descriptions always match the current script state.

As for the style, I wasn't sure how it should be (though I kind'a guessed it), but since I had tried to put in the body and it had worked...

Anyway... thanks to both for the answers :)
Regards

 
Descriptor Scriptwright

There's no problem putting data URIs in your script, there is probably a limit on the size of the script you can upload anyway.
It would be nice if we could upload very small icons to this site to use in our descriptions, I can't argue that, though I know that not having this feature eliminates a lot of headaches. But, you know, the use of Data URIs would eliminate problem of other sites linking to the images (stealing bandwidth), however I think mostly just Mozilla supports it.

 
Descriptor Scriptwright

@znerp : your post is helpful to me - I actually never would have thought to try that.