Cannot create direct link to image hosted online - html

I was just trying to add a background image from http://wallpaperswide.com/rocky_peak-wallpapers.html to my website.
The link to the particular image is http://wallpaperswide.com/download/rocky_peak-wallpaper-1920x1080.jpg.
However, if I try to load the image from the second link, it doesn't load. If I paste the URL into my browser, it redirects me to the first link.
Why does this happen? Thanks.
Edit
I'm getting some answers that there is an HTTP redirect. I know I can download the file and use locally.
However, the problem is that I'm writing a script that dynamically takes an image from the wallpaperswide.com site and automatically getting the image that fits the person's screen resolution. I just scan the page for the links and try to use those links. I can't download every image from the site and have them locally...
Any suggestions?

Because http://wallpaperswide.com/download/rocky_peak-wallpaper-1920x1080.jpg is not an image, it's a document.
HTTP urls always point to documents, therefore the web server is able to process it and give you the appropriate result.

The website author has added a 302 redirect rule while accessing the links directly, so you can't embed that link directly. Instead, you can download and refer it.

Related

How to store HTML-Page inside QRCode?

i would like to create a QR-Code containing a very simple website. The problem is, i would like to store the page inside the QR-Code, not as a url pointing to a website. So the qr-code contains the source code to the whole page and works without internet.
My first though was to store the page inside the qr-code as a data url. Eg. "data:text/html;...". This does theoreticly work but so far i didn't find a qr-code scanner which is able to open it in a way the page would be displayed.
I found out some qr-code scanners open content starting with "javascript:" in the browser but i wasn't able to display a page that way either. (With "window.open" or "document.write" as example).
My best guess to create a qr-code, which most qr-code scanners would open in a browser, is to create one starting with http://. But i dont know a way to store the html source code in a url starting with http://.
Any help would be welcome :)
You can use the Data: Url Protocol and put your HTML directly into the URL Like a Link. Mozilla Guide here: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs
data:text/html,{html of your page}
Unfortunately, the browsers are going to block Data: URI for security reasons. The same for Javascript: URI.

Google Drive API not displaying thumbnail

I have an app that uses the Google Drive API, and I need to display the thumbnails. But when I pass the link to an <img> tag it responds with a 404, but if I open the link manually in another tab in my browser it display just fine
You want to put the thumbnail of the file retrieved from Google Drive to your HTML.
The thumbnail link is retrieved by Drive API.
When you put it and open the HTML, 404 is returned. But when you directly access to the URL of the thumbnail link, you can see the image on your browser.
I believe your goal and your issue like above. For this, how about this answer?
Issue and workaround:
From your situation, I think that when you directly access to the thumbnail link, you might have logged in Google Account. By this, the image can be seen. And also, I thought that you might have used the following thumbnail link. This is the thumbnail link retrieved by Drive API.
https://docs.google.com/feeds/vt?gd=true&id={fileId}&v=1&s=###&sz=s220
Unfortunately, it seems that this link cannot be directly used at the HTML of outside. So in order to use the thumbnail at the HTML of outside, how about changing the endpoint?
Modified endpoint:
https://drive.google.com/thumbnail?sz=w640&id={fileId}
Please replace {fileId} of your file ID.
w640 means 640 pixels in the width. If you want to change the height, please useh instead of w.
Please share publicly the file you want to retrieve the thumbnail. It's On - Anyone with the link. By this, above link can be used. Please be careful this.
Note:
When the following HTML is used with the above link, the thumbnail can be seen.
<img src="https://drive.google.com/thumbnail?sz=w640&id={fileId}">

Google Drive images in img src=webContentLink?

Can I use images stored in Google Drive to be used in a website by the html,<img src="<webContentLink>" /> ?
Where <webContentLink> is returned after a file is uploaded and is in the format, 'https://drive.google.com/uc?id=<FILEID>&export=download'
I have a small website created for account users only. They can upload files to their google drive folder and this folder has permissions set to share with the accounts of the other users (specific people only). This is an ASP.NET MVC 5 website using the Google API Client Libraries for .NET.
In Chrome and Firefox the images display fine, in IE and Safari they don't show and return a 302 status code. Sometimes if you view the image directly in a new tab and then refresh the web page it shows. It might also show if the folder permission is set to 'anyone with the link', but this isn't ideal.
The documentation (https://developers.google.com/drive/v3/web/manage-downloads) says, 'If you want to allow a user to view a file directly in a web browser instead of through the API, use the webContentLink.' I understood this to be okay to use img src='' to display an image directly without the API, however it then goes on to say, 'You can either redirect a user to this URL, or offer it as a clickable link'.
So can Google please confirm if 'webContentLink' can be used in img src='', or not and why it works in some browsers and not others? I've read many posts on this, some old, some more recent. If it's not to be used in img src I think it should be made clear in the documentation.
Many thanks
Yes, you can definitely use webContentLink as your img src in your HTML page. I tried and this is what I got on my sample HTML page.
<img src = "https://drive.google.com/uc?id=0Bzgk4zncCwI7aDZCSHY4YU0zNUF&export=download">
webContentLink can be obtained using Files.list and place 'files' in the fields parameter.
Displaying an image from Google Drive can be done in 3 steps:
Retrieving your image ID
Right click on your image and select Share.
You'll see a link that you need to copy. You will extract the image's ID from the URL.
Here is what your sharing link should look like:
https://drive.google.com/open?id=YourFileId
Check your sharing settings
Your images will only be visible to people who have access to those files. To allow anyone access to your images, you need to set the sharing setting as Visible with the link.
Display your image
With your sharing settings properly configured and your image file IDs at hand, you can now specify how your images will be displayed using a prescribed format.
https://drive.google.com/thumbnail?id=YourFileID
More details can be found here
when I do this I just get a sign like an nonexistent image.
Why?
I just copy paste this line:
<img src = "https://drive.google.com/uc?id=0Bzgk4zncCwI7aDZCSHY4YU0zNUF&export=download">
JS Fiddle

HTML image doesn't loud from GOOGLE CLOUD

I have minimal knowledge of coding but I just spent the past 6 hours trying to resolve this issue.
Go here to see the image I am trying to have load.
If I am suppose to chance the SRC lines, how and where do I do that?
The HTML image loads perfectly from my computer.
Like what #mlegg said, I get the same error when trying to go to your link. It looks like that is no longer a valid URL or there is some form of security on it so it's only accessible from your computer (since you said it works from your computer?).
It could also be getting pulled from your browser cache if it was a good URL at one time. Try doing a Shift + Refresh of the page or purposely clear your cache.
If you have the image locally you could try uploading to a different web based repository and src it from there.
Just to cover all bases, I trust you know how to put an image on a web page using the img tag:
<img src="http://lorempixel.com/400/200/">
You might also want to try a different image that you know is available and accessible. You can use the URL above for lorempixel.com or you can scrounge up a different image from a Google Images search.

error accessing image, "file:///C:/Users/" not found

I made web site in html,but I have a problem when I click on some image in gallery, there is not new page.This is the error:
This webpage is not found
No webpage was found for the web address: file:///C:/Users/
"file:///C:/Users/" means that you wrote one or more html links pointing to your local hard disk (whoops). You need to find those links and rewrite them as relative URLs. http://www.google.com/search?q=relative+url+absolute+OR+file