Roope Posted May 13, 2013 Share Posted May 13, 2013 I'm building a product site where single product page wouldn't have any image field on it but instead we would use product images from another folder outside PW folders. All images are named using product SKU number that we store to text field during product import. Reason for this is that we already have images in place and we dont need (nor want) for images to be visible or uploadable through PW admin. Customer is used to mass update images via FTP and we don't want to break that. So question is, can we still use API to resize images or is it impossible outside wire array and filesystem? Link to comment Share on other sites More sharing options...
sakkoulas Posted May 13, 2013 Share Posted May 13, 2013 are you looking for something like this; foreach($page->images as $image) { $large = $image->width(500); $thumb = $image->size(100, 100); echo "<a href='$large->url'><img src='$thumb->url'></a>"; } details here Link to comment Share on other sites More sharing options...
Roope Posted May 13, 2013 Author Share Posted May 13, 2013 Thanks for your reply sakkoulas! No, this isn't quite what im looking for since I wouldn't have any image field attached to product template. Situation is more like this: // set root for product images $root = $config->urls->root . 'images/'; // set product image filename using product sku number $name = $sanitizer->pageName($page->sku) . '_01.jpg'; // get product main image $image = file_exists($root.$name) ? $root.$name : null; // now, resize image using PW API if ($image) $image = $image->size(300,200); Link to comment Share on other sites More sharing options...
Soma Posted May 13, 2013 Share Posted May 13, 2013 You could try using the ImageSizer class of PW. $im = new ImageSizer($config->paths->root . "myimages/IMG_09.jpg"); $im->resize(100,0); 2 Link to comment Share on other sites More sharing options...
Roope Posted May 13, 2013 Author Share Posted May 13, 2013 Yep, this looks right - thanks Soma! And ImageSizer seems to create new image to the same path as original so I think this should work just fine. I'll test it and report findings here! Link to comment Share on other sites More sharing options...
Roope Posted May 16, 2013 Author Share Posted May 16, 2013 OK, so this behaves as excepted. Defined image gets resized. But it overwrites the original file so this is not perfect solution for my need. Is there a way to make it create size variation from original without overwriting? I didn't find any options for this in ImageSizer class so how is it done in API? Should I just first copy and rename original image and resize that one? Link to comment Share on other sites More sharing options...
Soma Posted May 16, 2013 Share Posted May 16, 2013 Yeah the naming is done by the PageImage I think. Link to comment Share on other sites More sharing options...
ryan Posted May 17, 2013 Share Posted May 17, 2013 Should I just first copy and rename original image and resize that one? Yes, this is basically what Pageimage does internally. You can use PHP's copy() command. 2 Link to comment Share on other sites More sharing options...
Roope Posted May 24, 2013 Author Share Posted May 24, 2013 Thanks! I got sizing working really fine here. Link to comment Share on other sites More sharing options...
cb2004 Posted August 20, 2015 Share Posted August 20, 2015 Just tried doing this but it doesn't seem to work anymore? Error: Exception: our-history.jpg - not a recognized image (in /home/sites/MYSITE/public_html/wire/core/ImageSizer.php line 260) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now