Jump to content

Set image focus through API


Gideon So
 Share

Recommended Posts

Is it possible to set page image focus through a hook??

I tried this piece of code but it seems doesn't work.

wire()->addHookAfter('Pages::saveReady', function ($event) {
    $page = $event->arguments(0);
    if(count($page->pageBanner)){
      $page->of(false);
      $page->pageBanner->focus(10,10);
      $page->save();
      $page->of(true);
    }
});

Processwire throw this error:

Quote

Method Pageimages::focus does not exist or is not callable in this context

Any ideas is much welcome.

Gideon

 

Link to comment
Share on other sites

In case someone need the solution:

wire()->addHookBefore('Pages::saveReady', function ($event) {
    $page = $event->arguments(0);
    if(count($page->pageBanner)){
      $page->of(false);
      $page->pageBanner->first()->focus([top],[left]);
      $page->of(true);
    }
});

Gideon

Link to comment
Share on other sites

  • 3 years later...

I don't know and it's very hard to find out because everything image related in the CMS is very unreliable for lack of a better word. I don't know if the images are cached somewhere, on the server, in the browser? Any changes I take don't have any effect, setting the image focus manually in the input dialogue, not even rotating or flipping changes anything. I delete all image variations, rename the images, nothing helps. All stays the same so it's hard to say if the API is correct or not.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...