dachshund Posted June 15, 2009 Share Posted June 15, 2009 hi, i have a blog on my website, which i would like to include on the main page in a condensed down format as well as on its separate blog page. in the 'content' part there is both text and images, all the images are uploaded to my hosting at 500px wide. on the main page i would like the blog to be condensed down to 200px wide, the only problem is these images are 500px and i don't know how to resize them because there's text in there as well. is there anyway to find out if there are images in the post, and if there are, resize them proportionally to 200px wide. my code at the moment looks something like this <?php $sql="SELECT * FROM entries ORDER BY id DESC LIMIT 5"; $result=mysql_query($sql); ?> <table width="100%" border="0" align="center" cellpadding="5"> <?php while($rows=mysql_fetch_array($result)){ ?> <tr> <td align="left" bgcolor="#FFFFFF" class="blogtitle" valign="top" colspan="2"> <? echo $rows['title']; ?> </td> </tr> <tr> <td align="left" bgcolor="#FFFFFF" valign="top" colspan="2"> <? echo $rows['content']; ?> </td> </tr> <tr> <td align="left" bgcolor="#FFFFFF" class="bottomborder" valign="bottom"><? echo $rows['date']; ?></td> <td align="right" class="bottomborder" valign="bottom"><? echo $rows['postedby']; ?></td> </tr> <?php } mysql_close(); ?> </table> any help would be much appreciated. thanks Link to comment https://forums.phpfreaks.com/topic/162305-shrinking-a-blog-including-images-down-to-200px-width/ Share on other sites More sharing options...
rtadams89 Posted June 16, 2009 Share Posted June 16, 2009 The exact code would depend on the format of the image tags in your blog content, but couldn't you just load the blog post into a php variable, and use something like str_replace("<img width = 500", "<img width = 200", $blog_content_var) ? If the imgage tags are not consistant, you could use a regex to find and replace them. Link to comment https://forums.phpfreaks.com/topic/162305-shrinking-a-blog-including-images-down-to-200px-width/#findComment-856920 Share on other sites More sharing options...
dachshund Posted June 16, 2009 Author Share Posted June 16, 2009 hmm, the thing is there are videos on the blog too, from youtube and vimeo. i take it this is going to be pretty hard to do? is there any easier way? Link to comment https://forums.phpfreaks.com/topic/162305-shrinking-a-blog-including-images-down-to-200px-width/#findComment-856975 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.