The #1 Trick to Get High-Resolution Instagram Images
I love Instagram. The community is friendly, the photography is incredible and the algorithm sucks. While I have personally been using Instagram for years, we just got one for this blog, so if you don't follow us yet, please do.
One challenge I've had over the years is copying images off Instagram. Yes, I could go to Instagram on my computer and hunt through the source code until I found the image, but if somebody isn't familiar with code, it can be intimidating.
It can also be cumbersome, especially if I want to make my own Instagram feed. I don't want to write a script that crawls Instagram pages's DOM just to find a link to an image. If I have the current URL of my post, why can't I just get a high quality images from it?
You can! And It's really easy!
If you have the URL of your Instagram post, similiar to the following:
Simply append /media?size=l to the end of it. (Note, that's a lowercase "L", not a 1.) This "query string" sends a request to Instagram that you want a "large" size version of the image. Depending on when you posted the picture, some images may only be 640x640 in size. These days they are closer to 1000px in size.
The final URL will look like this:
Here's a high-res Instagram image as an example:
After that, either right click on the image and "Open image in new tab" and then "Save image as...".
You can get this from any account, as long as the account is public.
There is one minor catch with doing this method, however. Instagram encodes their images so that they can't be opened in some image editors like Adobe Photoshop. A simple way to get around that is to open the image in a program like Microsoft Paint first and then resave it. If you're just looking to upload the image onto social media or use it on your website, though, you can skip that step.
If you just want one picture at a time, then that's it! But, if you want to get multiple pictures at a time, keep reading.
Making This Into a Feed
That's a fun little trick, but you probably want more. Let's say you want to create an Instagram feed on your site that isn't powered by a 3rd party. A lot of these 3rd party websites redirect users from your site to theirs when people click on the images. If you want to take out the middle man and build you own feed, you can, and it's easy too!
First off, you need to generate an access token to get the feed. Go to the official Instagram Developer Authentication page. Click on the top right to login to your Instagram account. If you are already logged in, click on "Manage Clients". Here you will have to create your "client" or app.
When you're done that, click on "Manage" for the client in question. After this point you have two options to get your access token: "Server-side (Explicit) Flow" and "Client-Side (Implicit) Authentication". I prefer the "Server-side (Explicit) Flow" option because it's more secure, but the "Client-Side (Implicit) Authentication" is easier. We'll discuss both:
Server-side (Explicit) Flow (More Complicated But More Secure)
First you'll need your "Client ID" from your recently made client. Add it to the the following URL, along with the redirect URL you put into your client when you created it:
From here, you will get a login screen. You are logging into Instagram's official system so you don't have to worry about a 3rd party stealing or selling your information like you would if you use a random feed generator you find online.
Once you login, you'll be redirected to the URL you provided, but you'll have a code query string appended to the URL. Copy this code somewhere safe or write it down.
After this point, you'll need to create a PHP file. If you aren't comfortable making a PHP file on your server, you can always do the other method to get your access token. But, this script is fairly straight forward and doesn't harm the security of your site in any way. In the following code we are using the cURL command, which simply "calls" the URL in question and then prints whatever is generated.
To modify the code below, do the following:
- Replace CLIENT_ID with the Client Id Instagram provided you
- Replace CLIENT_SECRET with the Client Secret Id Instagram provided you
- Replace REDIRECT_URL with your redirect URL from before
- Replace CODE with the code you just generated
You should then get something that looks like this:
The top (in this case blurred) line is your access token. Copy that somewhere. You can delete this file now, if you'd like.
Below this we will discuss the non-secure way to get the token. If you're not interested in this, skip to the final section
Client-Side (Implicit) Authentication (Less Complicated But Less Secure)
Click on "Manage" and access your recently made client. Then click on "security". If you scroll down, you'll find a checkbox that says "Disable implicit OAuth". Disable this.
Now go to:
But replace the "CLIENT-ID" with your Client Id, and the "REDIRECT-URI" with the redirect URL you entered when you created your client. You should then come to a login screen. All this is doing is confirming you are who you say you are. You're simply giving Instagram access to your account. If you were going through a 3rd party application, they would be requesting access to your account, which is something you probably don't want.
After logging in, you'll be redirected back to your URL, but you'll have an access token appended to it. Copy that somewhere.
Using your Access Token
Now that you have your access token, go to:
Replacing "ACCESS_TOKEN" with your new token. This will generate you an JSON feed of your Instagram. If you want to control how many images show up, you can append &count=NUM to the end of the URL, changing the number to whatever you'd need.
From here you will need another PHP file. In this one we will loop through the JSON data and get the information you need. Simply copy the following code, replacing the information as needed:
This will give you something like this:
From there you can tweak your CSS and make the feed fit your theme!
Do you have any questions about getting the high-res Instagram images? Or how about making the Instagram feed? Tell me about it in the comments below!