Jump to content

Manipulate uploaded image before saving


chrizz
 Share

Recommended Posts

Hi everyone,

I'm new to PW and the last days I spent a lot of time to understand the concept behind. As far as I get it, I can truely say: "WOW, that's great!"

BUT - and thats the point I glad that there's a very cool forum as well - I'm dealing with a problem which seems very easy, but until now I did not find any solution. 

I want to build a small gallery. For a single gallery page the user can only upload one image. I started to build my own process (adding, page, upload image, enter some text, etc) but then I read about hooks. The only reason building an own "gallery management" is the control over the image:

- every uploaded image should be stored in a special folder

- the image filename should be identical with the page title

- every image contains a watermark

Each above requirement is not that problem when using a induvidual process but I want to take advantage of the given inputfields and I don't want to clone the page add/edit functionality. 

So I started to work on the helloworld.module to add a hook when uploading an image via AJAX. So far so good, but I have no clue how to manipulate the uploaded image before it is processed by the regular upload methods and added to the page.   

I would be very glad if someone can give me a hint for this. 

Thanks in advance!

Chris

Link to comment
Share on other sites

Hi Chrizz, welcome to the forums.

Here is code for a module that hooks into the event you are looking for. Maybe it is a good starting point for you: http://processwire.com/talk/topic/4517-random-images-file-name/#entry44392

---

Also worth to look at, (if you don't know it now), is Somas ImagesManager: http://processwire.com/talk/topic/3219-images-manager-alpha/

and maybe for watermarking the PageImageManipulator: http://processwire.com/talk/topic/4264-release-page-image-manipulator/

---

EDIT: @Chrizz: after rereading your post I think the best way for you would be to use Somas ImagesManager because it does most of what you want and if you need to adjust something you also can hook into it like I have done with this module: http://processwire.com/talk/topic/3398-working-with-processwire-getting-exif-data-from-images/#entry33552

Edited by horst
  • Like 1
Link to comment
Share on other sites

sorry for this late reply. Thanks a lot for this links. I found a lot of useful things (as you expected, I guess) to understand PW. 

Although the ImagesManager and the Manipulator are really cool I decided to code something on my own - not because I don't like the modules but for a better understanding. So after some long nights I have my own admin pages which can manage uploads (with watermarks) and creates pages etc...

The next step will be creating some templates. Perhaps I'll ask someone, something again :D

thanks again,

Chris

  • Like 2
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...