Web dialog not displaying local image
-
I have a web dialog that is being migrated from local html to being remotely hosted.
The only part that is not working, is the setting of the image source. It must be some sort of permissions issue I figure.
I am firing something like:
d.execute_script("document.getElementById('#{myimg}').src='file:///path/image.jpg'")
Which works fine if the html is local!If this is some security built into the Safari web dialog engine.... Do I have to feed the image as a binary string?
Many thanks for any help!
--J
-
what does WebInspector tell you when you run it on the webdialog in SU...
where is the html page hosted?
does the image need to be dynamically loaded?
and yes there a couple of base64 encoded images used in examples in the forum...
search for toolbar button may find one...
john
-
normally the 'link' for web data is http://www.url.com/images/image.jpg
is the result of your [file://path](file://path) something similar? -
To recap, moved an HTML page from living in its plugin folder, to living on our web server.
Everything with it is working fine, except for setting the image source to a local jpg.It does need to be dynamically set.
When I inspect it, the image SRC is set, the image is just not displaying.Thanks for the tip on base64, it's looking like I'll need to go that route.
--J
-
kaas reminds me that when running my own server I used something like...
src="file;//localhost#{/path/to/file}"
I'll see if I can find any of that stuff...
john
-
Okay, so it is just a permissions issue, browsers don't allow loading a local image from a remote page.
So in terms of feeding the image to the dialog, I'm not having success. Here is what I have, which is not working:require "base64" jpg = "/path_to_image/fancy_image.jpg" s = File.binread(jpg) b = Base64.encode64(s) @dialog.execute_script("document.getElementById('preview').src='data;image/jpg;base64, #{b}'")
I'm sure I screwed up something simple, thanks helping me to find out what!
--J
-
here's that toolbar example http://sketchucation.com/forums/viewtopic.php?p=363402#p363402...
personally I avoid jpg like the plague and would go for png...
require 'base64' File.open('imagetobase64.png', 'r') do |image_file| puts Base64.encode64(image_file.read) end
john
Advertisement