0

i want the picture here PNG Image

to be shown within my html under the header and grab it using curl. but it shows the text.

<html>

 <h1>SUMMONER ICON</h1>

<?php
 ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);

$image = curl_exec($ch);
curl_close($ch);
echo $image;
?>

</html>

1 Answer 1

2

To embed an image in HTML, you don't need to download it with PHP. Simply embed it in the HTML:

<img 
    src="http://ddragon.leagueoflegends.com/cdn/4.18.1/img/profileicon/711.png"
    alt="" />

You should note, however, that this type of embedding remote images (called “hotlinking”) may be undesired by the owner of the remote site. Please ask them before hotlinking.

Also note, when the image is removed some day, it won't be displayed anymore. Therefore, the best thing would be to download the image and upload it to your own server (assuming you are legally allowed to do so). Then change the src attribute to point to the correct URL on your own server.

1
  • im dumb for not thinking and i can just pass the php into the link. thank you! Nov 4, 2014 at 0:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.