guls_guys Posted June 19, 2008 Share Posted June 19, 2008 Hi guys i am new to php and need help in pasrsing img tag "<img src=\"images/hocnorwich/productInfo.jpg\" alt=\"Sophie Evening Gown\" title=\" Sophie Evening Gown \" width=\"105\" height=\"143\" />" i want to change the width and height of image to 50% of current size so how can i do this possible by parsing the string or making tokens or might be using some regular expressions (which i dont know how to use) and i want to do it in php hope to get a swift answer cheers salman Link to comment https://forums.phpfreaks.com/topic/111020-parsing-tag/ Share on other sites More sharing options...
jmelnick Posted June 19, 2008 Share Posted June 19, 2008 Hello, I would use image functions to read the image directly, get the actual width and height, and build the image tag with the height and width set to calculated to 50% of actual size. Cheers, Joseph Melnick Link to comment https://forums.phpfreaks.com/topic/111020-parsing-tag/#findComment-569706 Share on other sites More sharing options...
guls_guys Posted June 20, 2008 Author Share Posted June 20, 2008 thanks mate problem is i dont get the image uploaded directly so i dont get its path what i get is this variable with the complete img tag so how can i read info from it and build new tag cheers salman Link to comment https://forums.phpfreaks.com/topic/111020-parsing-tag/#findComment-569968 Share on other sites More sharing options...
guls_guys Posted June 20, 2008 Author Share Posted June 20, 2008 hi guys found the solution $src=htmlentities($proImg,ENT_NOQUOTES);//$proImg got the string which i want to change $src = preg_replace( '/(width|height)="\d+"/', '$1="10%"', $src); echo $src= html_entity_decode($src); Regards Salman Link to comment https://forums.phpfreaks.com/topic/111020-parsing-tag/#findComment-570031 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.