ryan

PW 3.0.89 – Core updates

Recommended Posts

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/

  • Like 19
  • Thanks 5

Share this post


Link to post
Share on other sites

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.

  • Like 1

Share this post


Link to post
Share on other sites

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. 

  • Like 2

Share this post


Link to post
Share on other sites

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

 

 

Share this post


Link to post
Share on other sites

@Juergen works for me. Your $image is null, so check that you're on the right page/have the right field name.

  • Thanks 1

Share this post


Link to post
Share on other sites

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());

 

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

I installed the module, converted the field and nothing changes for me.

Share this post


Link to post
Share on other sites

Strange behavior, I have to investigate further. What I also have discovered is that the duplicate action is no longer present in the dropdown. ???

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
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.

  • Like 1

Share this post


Link to post
Share on other sites

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>

 

  • Like 1

Share this post


Link to post
Share on other sites
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. 

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Recently Browsing   0 members

    No registered users viewing this page.