Jump to content

Resize methods in admin


steveooo
 Share

Recommended Posts

Hello,

for a module that's used in the admin, I need the ->size(x, y) functionality for creating thumbnails of existing images.

I tried it but I got following exception:

ProcessWire: ProcessPageList: Method Pagefile::first does not exist or is not callable in this context

I hope someone can help me with that!

Thanks!

Link to comment
Share on other sites

  1. you need to get the page
  2. then get the imagesfield
  3. then select the desired image
  4. do the resize

Will say, it is done as always. Where is your page that holds the imagesfield? Do you have a path, a name or a id of it?

// within a modules method you will do something like

1) $p = $this->pages->get(YOURPAGESELECTOR);

2) $images = $p->yourImagesField;

3) $image = $images->first(); // or whatever you like

4) $image->size(x, y);

PS: Please do not send me PMs with something like: "how can I do xy, please help its urgent."

Use the forums support thread or the job section!

  • Like 2
Link to comment
Share on other sites

Hello,

Thanks! I thought this would be the way. I got my file object (one test: I can use $file->ext and get the correct file extension), but still something like $file->size(100, 75) does not work.

EDIT:

Well, if asked: I only use JPG. Resizing a DOCX would be fun :D

Link to comment
Share on other sites

Ohh.. Okay. I am using a File inputfield -.-

Can I somehow transform this File object into an Image object or do I always need a "imageField" and "NotImageFiled"?

Do you want use image functions or do want not? If you want use image functions, I suggest to use an images field, that's what they are built for.

Link to comment
Share on other sites

Well. I got a single upload field for and I do not want my clients to select images and files first in order to upload these. So I want a single upload field and this is only possible if I got 1 field. But it seems that I need to separate them..

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

×
×
  • Create New...