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
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;
}
    
}

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.