ryan Posted January 26, 2018 Share Posted January 26, 2018 This week we’re back with a new dev branch version that adds a new feature we think you’ll like: focus point image cropping. That’s also the “focus” of this blog post. This version also includes resolutions to numerous issue reports and more. https://processwire.com/blog/posts/pw-3.0.89/ 19 5 Link to comment Share on other sites More sharing options...
SamC Posted January 26, 2018 Share Posted January 26, 2018 Can't wait to try out the new focus feature! One question, I haven't tried it, just seen the vid (on the phone now). Does this replace the 'cropping' => 'southeast' from the $options array? What happens if you crop "ne" at 400 x 200 (from an image 1000 x 800) for example then use the focus tool in the page editor? This new feature looks like I can throw all my pre-empting out the window, leave crop at centre, just set the size and use focus. Which would be awesome. 1 Link to comment Share on other sites More sharing options...
arjen Posted January 27, 2018 Share Posted January 27, 2018 Good to hear you and your family are doing fine Ryan. As always nice solution for a problem which seems to resolved by fixed crops, but this is a way better UX for the content editors. 2 Link to comment Share on other sites More sharing options...
Juergen Posted January 27, 2018 Share Posted January 27, 2018 Great addition, but I have problems focusing images via $page->children call. Description: If I output the image on the same page the focus works, but if I call it from another page I cannot get the focused image. Focus is centered in this case. foreach ($page->children as $child) { $image = $child->myimagefield; print_r($image->focus()); } This will lead to following error message: Call to a member function focus() on null. Can someone confirm this behaviour? Best regards Link to comment Share on other sites More sharing options...
fbg13 Posted January 27, 2018 Share Posted January 27, 2018 @Juergen works for me. Your $image is null, so check that you're on the right page/have the right field name. 1 Link to comment Share on other sites More sharing options...
Juergen Posted January 27, 2018 Share Posted January 27, 2018 The image is there and now I get the focus coordinates if I remove the brackets. This works: print_r($child->singleimage->focus); but this not: print_r($child->singleimage->focus()); Link to comment Share on other sites More sharing options...
fbg13 Posted January 27, 2018 Share Posted January 27, 2018 @Juergen I get null without parentheses. What PHP version are you using? I'm using 7.1.13 Link to comment Share on other sites More sharing options...
Juergen Posted January 27, 2018 Share Posted January 27, 2018 I use 7.0.27. I have croppable image installed too. My first thought was that there is an interference between the default image field and croppable image 3. Link to comment Share on other sites More sharing options...
fbg13 Posted January 27, 2018 Share Posted January 27, 2018 I installed the module, converted the field and nothing changes for me. Link to comment Share on other sites More sharing options...
Juergen Posted January 27, 2018 Share Posted January 27, 2018 Strange behavior, I have to investigate further. What I also have discovered is that the duplicate action is no longer present in the dropdown. Link to comment Share on other sites More sharing options...
Juergen Posted January 27, 2018 Share Posted January 27, 2018 Ok, I have created a new image field and now everything works fine. So it seems that there was a problem with my old image field. Link to comment Share on other sites More sharing options...
Juergen Posted January 27, 2018 Share Posted January 27, 2018 Ok I found the cause. There was a wrong setting in my image field. You have to set it to output an array of elements instead of a single element. My image field only allows 1 image so I set it to auto. This caused the behavior. Link to comment Share on other sites More sharing options...
SamC Posted January 27, 2018 Share Posted January 27, 2018 OMG just tried it out, this feature is KILLER! so much easier now, just set some image defaults (i.e. quality) and leave the rest (cropping to true rather than n, s, se, nw etc.), then just adjust image by image in the admin, amazing. Thanks @ryan Unlike @Juergen above, my image field only allows one image and it works fine. Link to comment Share on other sites More sharing options...
Juergen Posted January 27, 2018 Share Posted January 27, 2018 2 hours ago, SamC said: Unlike @Juergen above, my image field only allows one image and it works fine. The cropping works now also fine in my case, the only difference is in outputting the coordinates. If it is an image array you can use $image->focus() but if your image is not in array you have to use $image->focus -> without brackets I was a little bit confused for the first time, because I have used a square crop and therefore the crop focus seems to be in center instead of the coordinates. So I wanted to check if the focus coordinates are still there. Therefore I have needed to output the coordinates. 1 Link to comment Share on other sites More sharing options...
SamC Posted January 27, 2018 Share Posted January 27, 2018 Sorry @Juergen I got my wires crossed here, I'm not using ->focus() at all. Just been messing about in the admin, I output just with: <?php // if page has single image field called 'featuredImage' if ($page->featuredImage) { // save some typing... $image = $page->featuredImage; // for demo purposes, don't leave this in! $options = array( "forceNew" => true ); $rec = $image->size(150, 75, $options); } ?> <div class="container py-5"> <div class="row"> <div class="col"> <img src="<?php echo $rec->url; ?>" /> <p> Changed width and height</br> Width: <?php echo $rec->width() . "px"; ?></br> Height: <?php echo $rec->height() . "px"; ?> </p> </div> </div> </div> 1 Link to comment Share on other sites More sharing options...
Tom. Posted February 9, 2018 Share Posted February 9, 2018 On 27/01/2018 at 6:42 PM, Juergen said: The cropping works now also fine in my case, the only difference is in outputting the coordinates. If it is an image array you can use $image->focus() but if your image is not in array you have to use $image->focus -> without brackets I was a little bit confused for the first time, because I have used a square crop and therefore the crop focus seems to be in center instead of the coordinates. So I wanted to check if the focus coordinates are still there. Therefore I have needed to output the coordinates. I would say that is a bug then, there shouldn't be, in my eyes, a difference in syntax between Single Image or Image Array. Link to comment Share on other sites More sharing options...
OLSA Posted February 12, 2018 Share Posted February 12, 2018 Thank you Ryan for focus point feature. Before this, I used option with select field where editor define focus point (crop from top percentages) - but right now it would be more precious and editors will like it more! Thanks. 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