I ran into a very annoying, and strange problem with loading pictures, using a custom handler (we need to mask the pictures runtime).
The Website, where you can check it out: http://utazovilag.hu/Test/Stack/Main.aspx
The basics: As I stated above, I use a custom image handler for loading and modifiding images at runtime. This site offer different travels, each changed frequently (changing the price, mostly). Each hotel have an own set of pictures, where we put an "advertisement" bar on it (a semi-transparent black rectangle, with some text). This handler load the image (some from the local server, some from another URL source), and draw the needed text and pictures on it, then give back the picture itself on the Response stream.
The error: The above should work well, but strangely, the pictures itself sometimes simply dont load at all. (if you check the site on the above link, you can see it for yourself - there should be six pictures, inside a rouded bluish border). When I refresh the page, pictures appear and disappear, without any (for me) logical pattern.
I narrowed down the problem as best as I could.
The imageHandler itself will give back the exatly same pictures each
time, no matter if it gets any URL or not.
The problem is with the ImageBoxes (I think). When I give the "plain"
url (one without any parameter, even when the handler dont even check
if there any parameter)
When I add the URL for the imageBoxes (this
one:http://utazovilag.hu/Test/GetTestImage.ashx) this will give the
perfectly good image back, and each imagebox will load without any
error.
When I add the URL with SAME parameters, its work like as it should
(like: http://utazovilag.hu/Test/GetTestImage.ashx?OID=0&PID=0&SID=0)
it works as it should.
(And now, the error) when I add an URL with different parameters, its make the pictures randomly pop up and dissapear between each refresh (this what you can see on the link I gave you above) Like this: http://utazovilag.hu/Test/GetTestImage.ashx?OID=0&PID=0&SID=0 And this: http://utazovilag.hu/Test/GetTestImage.ashx?OID=1&PID=0&SID=0
But when I hit the "Refresh Image" button, the image appear as it should. When I try to acces directly the GetTestImage.ashx, it appear as it should. The load problem only appear when there is more picture boxes, with different URLs.
I simply ran out from ideas, and cant imagine why is this happening. I tried to create the most basic imageHandler (it simply load the image, create byte array, and push that to a stream toward the user). I tried different browsers, (Firefox, IE, Chrome) - all of them give the same error (or, no error, as simply the picture not showing up).
Any ideas would be really-really appreciated.
Edit: Here is my imageHandler: http://pastebin.com/FjjUmNzW
Edit1: I forgot to mention it: it runs fine on my local machine, this error appear when I try to run it on the server.
Edit2: Updated the handler code as well, I showed where I put the log-asking.
Set the IsReusable property to true to handle multiple images. There is no MSDN documentation for this the last time I looked. But this is what I use for displaying say, a list of product images.
public bool IsReusable
{
get
{
return true;
}
}
Apparently, this keeps the handler in memory and able to handle multiple requests. When set to false, it had to create a new instance of the handler for each incoming request.
Related
I have a Xamarin.Forms app that opens locally saved HTML files which contain relative link to each other (think an old HTML offline docs) in a WebView. Everything functioned in Android 10, but now I needed to make a custom renderer in Xamarin.Android due to the new Android 11 changes needing AllowFileAccess (I have all accesses currently on for testing until I get this problem fixed) in the WebSettings. The WebView's OnElementChange sets all the Control's settings, sets the WebClient (which has a ShouldOverrideUrlLoading set to handle particular filetypes like PDF), and then loads the URL. The first page loads fine, but none of the links operate (this testing page has a few links to other HTML pages and some to PDFs). Click on the highlights them as normal, but nothing opens.
No breakpoints in the WebClient's ShouldOverride are hit and neither are any in the Android WebView's OnElementChanged when I click a link. The output window registers the touch, but doesn't do anything more. I feel like this is some kind of communication problem between Xamarin.Forms WebView and Xamarin.Android WebView (possibly even the Xamarin.Android's WebView not being up to date with Android's WebView), but I do not know where to look. Has anyone run into a similar situation and have a fix to get the links functioning again?
Thanks.
After much blood, sweat, and tears, mostly tears, I found the solution.
First off, WebView doesn't tell you directly, but anything that targets a new window (IE _blank and potentially others) will not hit your WebViewClient's ShouldOverrideUrlLoading method and instead hit your WebViewChromeClient's OnCreateWindow method. So you need to handle loading through that one as well as through your WebViewClient.
Second, links will not always work because of Safe Browsing in the WebView. Again, Google doesn't specifically say it can cause issues with urls, but it works against outside urls (which in a file is potentially every url). I had to turn it off, which you can find instructions at developer.android.com/guide/webapps/managing-webview, and I was able to navigate just fine. I feel you will want to set up safeguards to prevent people from abusing your app (like having a WebView that is for your stuff with Safe Browsing off and another for all others, or blocking any sites that aren't yours) since cybersecurity is always a thing.
Lastly, I found IFrames won't load properly if you manually load the page in the view passed to WebViewClient's ShouldOverrideUrlLoading. The sizing goes all off in my docs, which leads me to believe the elves in the background do something special if you return false and the WebView handles it. I found I needed to handle all my other cases (IE pdfs, images, etc) and then return false from ShouldOverrideUrlLoading if it is my iframe htmls.
As a note, because I had forgotten this having worked on Windows for so long, remember that Android's base file system is case sensitive, which makes links case sensitive. You need to either makes sure all your casing is correct in your files or have them on a FAT file system SD card if you want them to be insensitive.
I would like to confirm what effect this CSS code has on the homepage of a wordpress website.
.lazy { display: none !important; }
Many thanks for explanations.
I have noticed images in the homepage are being blocked from being displayed which is why im asking this question.
The CSS code itself, prevent any element which has it from being displayed on the screen.
Due to its name, it may be used to enable something called lazyload (you can read about it here).
lazyload is usually used for several reasons:
Remove the pressure of loading many images at first; sometimes images are placed at the end of the page so the client won't see it at the top of the page, with lazy loading trick it. You can prevent those images from being loaded, and force them to load only the moment your client reach them by scrolling or other events so it cause page loading improvements (because the page is now lighter)
For making some visual effects; almost everywhere you need the image to be hidden and after some juggling or some specific events it is shown (like wp-admin and sub-menus, which will be shown if you hold your mouse on or click them)
etc
Recording to the reasons; I guess your kind of codes (which will be handled in client-side and client browser) does not fit the first reason and may be used for the second one because for the first reason it is better (and I guess it must) implemented on server-side. Why? Because in your code, the image is loaded and be will there and just not shown because of the CSS code
This was all I know but if you want a more specific answer you have to say where you saw it in WordPress, in a plugin, wp-admin, template, etc...
Hope the answer becomes handy for you
I have a QGraphicsWebView to which I construct a page by appending tags. For example:
webElement.appendInside("<img src=<img src=\"qrc:/img/ioLlogoTopLeft.png\" />");
This happens in a secondary QThread. I also use resources to set styling in the same thread:
defaultBaseFrame->setStyleProperty("background-image", "url(qrc:/img/ioLGradientTop.png)");
Both of these lines were working fine, but in the last few builds they've stopped working, and I've no idea why. Instead of an image I now get an empty frame, and the background fails to appear. The resource paths seem fine, and work fine in other (non web-view) parts of the program.
On the other hand, when I replace an image URL with a location on the internet (an http:// url), the image loads normally.
Is there some quirk to using resources in a multithreaded environment (or was that just a red-herring?) Resource images were working before, and I can't think of anything relevant in the code that I've changed recently.
Solved it. And not a particularly satisfying solution; more just a quirk of Qt. It turns out the problem started when I removed the (I assumed) redundant initialisation of the WebView to a blank page:
webView->setHtml("<html><head></head><body></body></html>");
When I re-added it, images in resource files started working again. There didn't seem to be any other difference in functionality; all the other page elements render the same, just that one little quirk was fixed.
Recall that I'm building up the page from a blank DOM tree. I had falsely assumed that the above line was redundant because QWebView always inserts those boilerplate HTML tags automatically regardless, and almost everything works as it should either way.
To start off, I have searched google & SO (Images are showing up as red x's on IE, shows up fine in other browsers), tried out the suggestions, but they did not resolve my issue.
I am trying to create a transparent image by following the code shown at: How do you Draw Transparent Image using System.Drawing?. I am using a 3rd party mapping control "Simplovation"
However, this is what I get when I run my webpage:
How can I get the actual image to appear?
I tried converting to RGB, but no luck.
Based on the code in "How do you Draw Transparent Image using System.Drawing" the actual image should appear like:
There could be a long list of potential problems here, let's address 3 of them:
Permissions
You imply that you are creating this image from code. How are you doing that? If the IIs worker process, running in the user context of the application pool account, is creating this image, does it create/save it to a location that is accesible anonymously? (or whatever your authentication model is)
File locked?
Again, since you are implying your are creating the image from code, to you close the file handle properly?
Path.
You say that the image Url is correct, but are you really 100% sure? Press F12 on IE and use the developer tools to determine if you get any type of HTTP error when IE is trying to request the image.
IE is very specific about the image type and actual image content. In other words, IE cannot display if image type and content doesn't match.
For example, renaming just file extension - bmp to gif - doesn't work in IE, although it is not an issue in other browser.
Easiest way to check is to browse that page in other browser. If you can see image in other browser, you can make sure that image format is not correct.
I have written a small picture script which shows a directory listing with thumbnails and also previews of the pictures.
Directory listing example
Image preview example
Source code
In some cases, when you click through several image previews (you can also use the arrow keys left/right to do that faster), some images don't fully load (and they are only shown partly then).
I think this has started to appear more often since I am preloading the next few pictures but it also has appeared before. This also occurs most often if you switch the images very fast.
I wonder why this appears and how I can avoid this. I guess that the browser somehow looses some connection to the server (or the server closes it unexpectedly for some reason). Thus I tried to work around this by setting Content-Length (and I was hoping that the browser would reconnect automatically if the file was not received fully) but that didn't helped.
Also, in the browser, a normal reload of the page doesn't help, I have to force a full reload.