Click here to Skip to main content
15,867,453 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I've tried to edit the image src from a webpage I want to show on my own webpage, like this:

PHP
$imgs = $doc->getElementsByTagName('img');
foreach($imgs as $img) {
    $img->setAttribute("src", "http://www.futwiz.com" . $img->getAttribute("src"));
}


But it shows up on the view source as this, and is not downloading the images. Does anybody know how to fix this?

HTML
<div class="card-15-face"><img data-cfsrc="/assets/img/fifa15/faces/167305.png" src="http://www.futwiz.com"><noscript><img src="http://www.futwiz.com/assets/img/fifa15/faces/167305.png"></noscript></div>
Posted
Comments
Sergey Alexandrovich Kryukov 19-May-15 16:05pm    
Not clear. First, the image, if the URL is correct, will be downloadable in all cases. Second, it's not clear why noscript is there. What have you done to put it there?
—SA
Member 11703322 19-May-15 17:43pm    
I haven't done anything -- when attempting to change the image source using a string and $doc->getAttribute("src") as the parameter for the setAttribute, it seems to put it in a noscript tag instead of when it is just a string as the parameter for setAttribute, where it works fine.
Sergey Alexandrovich Kryukov 19-May-15 18:10pm    
Do you have mixture of PHP and HTML code in your PHP file? Is there any noscript anywhere at all?
Could you make the comprehensive complete code sample, but as small as possible, yet manifesting this problem?
—SA
Mohibur Rashid 19-May-15 21:07pm    
There is a chance that the framework which is being used by op is creating that noscript tag. My suggestion is "pay more attention to your framework".
Sergey Alexandrovich Kryukov 19-May-15 22:05pm    
Hard to imaging that, but your advice about paying attention is very good. :-)
The inquirer simply does not make us enough information. Look at the file name in HTML: "167305.png". It is not mentioned in PHP code.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900