Is there an easier way to link an image?


While going through the lessons, I decided to practice linking to images on a practice web page. So, i went to google images and found some I wanted to put on my project site. However, the URLs are very long in my code editor and I was wondering if there was an easier way to condense it so it isn’t a large block of text.

@devjumper90556 Welcome to the forums! The only way I know how is to just copy and paste the URL. If you maybe did it on another file, within the parent file that you are using, you could maybe use local referencing, but that is non-standard practice, as far as I know; you are better off just doing it the original way.

You could create a shortlink, google shortlink creator.

Keep in mind that, usually, you would be expected to host the images you want to use on your page in the same place as your markup.

Pulling images from elsewhere on the web is a practice called Hotlinking and is discouraged.

Having the images locally also results in much shorter URIs in your image tags, since you don’t need to include someone else’s domain… :slight_smile:

If the URL of the image you want to “hotlink” is too long, you either try and reduce the size of the URL as some hostings add a lot of string queries after the .jpg or .png file so you could try and find where the actual image ends (looking for the actual filename) and delete everything after it and hit Enter. If it allows you to load the image with the reduced URL, use it. If not, perhaps save the file locally and put it somewhere in your app’s contents such as /images folder.

It is tantamount to theft, and a growing concern since way back when.

Google and other SEs actually look for the images folder on our server. That is where they like our images to be stored, at least the ones for which we want some potential of indexing.

When we hotlink, the crawler traces back to the source and credits them with the image, not our site. Too many of these tracing from our site and it is likely the the SE will move it into a supplemental index and we’ll likely never show up in SERPs. Hotlinking can kill our chances in the search game.

Depending upon how many images are in a particular page, we can give ourselves some advantage by using a CDN for images, and keep only source files on our host server. Typically, a client can only have two active ports on the server at any one time. But there is no such limit to how many servers we connect to, meaning if we have two servers, one for files and one for images, we can download them concurrently, two resources from one server, two from the other.