View Full Version : Help with php code on a template for images

09-07-2009, 01:38 PM
I have an interesting problem.

Our website publishes other sites RSS feeds (all above board I hasten to add). And we use php software to do this. The software basically publishes(prints) the feeds onto a .php template file which in turn is 'included' (using the <? include ("include/templatexxx.php") ?> command) on our web pages. There is often more than one feed published (included) on each page.

We have problems with images from some of our publishers that are far too big and we wish to be able to control the size of these images by reducing them all by say 50%.

I was wondering if anyone has a code that we can use on our php template pages that will automatically reduce the size of all images (img ) on the page.

Hope this makes sense.

09-07-2009, 02:32 PM
<img src="images/image.gif" width="50%" height="50%" />

That should do it.

09-07-2009, 03:15 PM
Vengeance probably meant to suggest the CSS solution rather than modifying the image tag itself since you'd probably need to parse the feed and modify the tags with that method - not exactly fun. Probably apply it to something like div#wrapper img {}.

If you're willing to go to the effort of parsing anyway, you might consider feeding the images to GD or ImageMagick to resize them all to a common size if larger than desired. The effectiveness would depend upon how you actually handle the content on your end.

09-07-2009, 03:21 PM
Vengeance probably meant to suggest the CSS solution

I actually had that in mind as a solution, but forgot about it for a moment. :D

09-08-2009, 04:16 PM

Thanks for all your help.

The CSS is the answer. Using the following:

<style type="text/css">
<!--img { width:80px; height:80px; }

Keep up the good work!!:thumbsup: