volatileboy Posted June 30, 2008 Share Posted June 30, 2008 Hey just a quick question, I have made a forum and I am using a standard bbcode method which include , I am stumped in finding a way to resize the dimensions of the image when the code is loaded onto the page. My problem isn't with the actual image resize, it's searching through the post text for the string match, getting out the parts I need and changing it with the new width and height. Does anyone have any help on this cos it's kicking my ass? Thanks for reading! Link to comment https://forums.phpfreaks.com/topic/112565-editing-html-image-code/ Share on other sites More sharing options...
MasterACE14 Posted June 30, 2008 Share Posted June 30, 2008 $_POST['width'] $_POST['height'] I assume you have a couple POST's similar to that? could you post some code related to this? Link to comment https://forums.phpfreaks.com/topic/112565-editing-html-image-code/#findComment-578094 Share on other sites More sharing options...
trq Posted June 30, 2008 Share Posted June 30, 2008 Sorry, you've lost me all together. bbcode, image size... what exactly are you talking about? Link to comment https://forums.phpfreaks.com/topic/112565-editing-html-image-code/#findComment-578095 Share on other sites More sharing options...
MasterACE14 Posted June 30, 2008 Share Posted June 30, 2008 I think he means he knows how to resize the image using HTML/CSS but is getting the actual dimensions from PHP to get the right resize, size. Link to comment https://forums.phpfreaks.com/topic/112565-editing-html-image-code/#findComment-578096 Share on other sites More sharing options...
volatileboy Posted June 30, 2008 Author Share Posted June 30, 2008 Sorry, my post was a little confusing, not to mention I didnt use code tags lol. Basically in user posts they can insert image urls like this forum with [ img] [ /img] tags, this is then converted with preg_replace, a shortened version of which is shown below: $patterns = array("/\[url\](.*?)\[\/url\]/","/\[img\](.*?)\[\/img\]/"); $replacements = array("<a href=\"\\1\">\\1</a>","<img border=0 src='\\1'>"); $str = preg_replace($patterns,$replacements, $str); This conversion from bbcode to html is done on page load and the images come out like this: <img border="0" src="http://www.url.com/picture.jpg"> I want to scan through the post and check for legit image tags or [img ] tags, use getimagesize() to find out it's dimensions and calculate it's new width and height and then replace the initial image string with a new one that won't destroy my page. If this can be done easier with CSS that would be great, I can't say im a pro with CSS but it would be a much easier option. Thanks! Link to comment https://forums.phpfreaks.com/topic/112565-editing-html-image-code/#findComment-578099 Share on other sites More sharing options...
MasterACE14 Posted June 30, 2008 Share Posted June 30, 2008 yeah, I got no idea sorry. Link to comment https://forums.phpfreaks.com/topic/112565-editing-html-image-code/#findComment-578120 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.