Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>First of all, my answer will only work if you are using ASP.NET (C#), but it can be easily ported to VB.NET, PHP, or something similar.</p> <p>If you load up the image in javascript, it will just look like a dead url and will throw an error when you try to load it.</p> <p>What I did was create a page that receives a URL for the image in the querystring, reads the image, and outputs the response.</p> <p><strong>WebForm.aspx</strong></p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function () { var image_url = "http://www.kottke.org/plus/misc/images/castro-pitching.jpg"; var $image = $('&lt;img src=LoadImage.aspx?imageUrl="' + image_url + '" width="50" height="50" /&gt;'); $('body').prepend($image); }); &lt;/script&gt; </code></pre> <p><strong>LoadImage.aspx (.cs Code-Behind)</strong></p> <pre><code>using System; using System.Net; public partial class LoadImage : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { String url = Server.UrlDecode(Request.QueryString["imageUrl"]).Replace("\"", ""); WebRequest req = WebRequest.Create(url); System.Drawing.Image img = System.Drawing.Image.FromStream(req.GetResponse().GetResponseStream()); Response.Clear(); Response.ContentType = "image/jpeg"; img.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg); } } </code></pre> <p>This appears to successfully load the image and display it, 302 redirect and all... There is no way, that I know of anyhow, to do this without some work on the server side.</p> <p>If you can't use .NET, but can use another language, or if you can't use any other language at all, let me know...</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload