A Twitter API request may get a tweet with an image, returning JSON that contains something like this (non-relevant bits removed)
["media"]=>
array(1) {
...
[0]=>
array(14) {
...
["media_url"]=>
string(46) "http://pbs.twimg.com/media/XXXXXXXXXXXXXXX.jpg"
...
["type"]=>
string(5) "photo"
["sizes"]=>
array(4) {
["medium"]=>
array(3) {
["w"]=>
int(1200)
["h"]=>
int(1200)
["resize"]=>
string(3) "fit"
}
["large"]=>
array(3) {
["w"]=>
int(2048)
["h"]=>
int(2048)
["resize"]=>
string(3) "fit"
}
...
}
...
}
}
How do you access the different sized versions of the image? I tried entering "http://pbs.twimg.com/media/XXXXXXXXXXXXXXX_medium.jpg" or "http://pbs.twimg.com/media/XXXXXXXXXXXXXXX_1200x1200.jpg" into the address bar (obviously with real images, as opposed to this example URL) but that doesn't come up with anything
The syntax is slightly confusing, but is described in the Twitter documentation.
The size name medium
needs to be added to the end of the URl.
For example:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With