Jump to content

Is this even possible?


cowboysdude

Recommended Posts

I am trying to make it so the user can change the thumbnail size of a picture.... this is what I've got because I had to do a str_replace to first add the width and height into the html on output.... NOW I'm trying to have the ability to resize them... here is what I currently have...

 

$videos[$i]['img'] = str_replace(">"," width=40% height=40% >", $matches[0]);

 

I have tried:

 

$videos[$i]['img'] = str_replace(">"," width=$xy height=$xy >", $matches[0]);

changing size by %... but it returns nothing in the html.

 

Then I tried to do a total substitute and do this...

 

<?php
$xy = $params->get('xy');
$xypic = " width=$xy  height=$xy >";
$videos[$i]['img'] = str_replace(">", $xypic , $matches[0]);

 

That doesn't work either it returns nothing in the html...

 

Is there a way to make this work?  I've tried a few different ways but no luck....

 

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/226308-is-this-even-possible/
Share on other sites

$rss = new SimpleXMLElement($data);
	$i = 0;
        $videos = array();
	foreach($rss->channel->item as $item){
            $videos[$i]['title'] = (string) $item->title;
            $videos[$i]['link'] = (string) $item->link;
            $description = (string) $item->description;
            $matches = array();
            
            preg_match("/<img[^<>]+>/",$description,$matches);
         $videos[$i]['img'] = str_replace(">"," width=40% height=40% >", $matches[0]);
		$i++;
		if($i>=$totalvid) break;
	}
	return $videos;
}
    
}

Please add some code around this line:

 

         $videos[$i]['img'] = str_replace(">"," width=40% height=40% >", $matches[0]);

 

So it looks like this:

 

print "Original string: {$matches[0]}<br>";
         $videos[$i]['img'] = str_replace(">"," width=40% height=40% >", $matches[0]);
print "Replacement: {$videos[$i]['img']}<br>";

 

then run the script and copy and paste the output

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.