Jump to content

Recommended Posts

Posted

no problem, your suggestion to do it by a new inputfield-file variant works perfect, i have a multiple-file field now, that executes the imagick scaling after upload und shows the generated thumbnail in the file-list. pretty good for the first step, as i think.

  • Like 1
Posted

is it possible, to add one of the generated images from the new file-field to an existing image-field on the same template?

Posted

Sure.

$page->imageField->add($path);

Thank you kobrakai,

i`ve problems to get the $page varible in my inputfield module. i'm not really familiar with modules in general, so maybe i don`t understand someting common here.

Posted

no. i've cloned the inputfield-file module to InputfieldFileApp.module (and copied FieldtypeFile.module as FieldtypeFileApp.module inside the folder). The new filefield works, i can use some custom functions inside, this is good. But now, i want to copy a specific version of a new uploaded file to another field, an image field on the same template.

inside InputfieldFileApp.module wire('page') is the edit page, not the page the field is on. thats logical, but doesn't help me out.

Posted

It would be more "update-prove" to just hook the existing modules and add in your needed function on runtime, but this works, too. Most inputfields work independent on any page context, like the file field. Therefore the Fieldtype does add some hooks to dynamically inject this information, to cater for changing uploadPaths (see setupHook). You could edit the called function to not only inject the path, but also the $page object into the inputfield. 

Posted

ok, thank, that helped, declaring $inputfield->editPage = $page; in the Fieldtypes hookProcessInput function i have the page-object in the inputfield module.

inside the ProcessInput function i create my image variants and with

$this->editPage->app_img->add($this->destinationPath.$filename."-app-web.jpg");
$this->editPage->save();

... i can copy the image to the app_img field in the background and it appears when saving the page. Is it possible to actualize the image-field after the add() is done?

Posted

That's not easily possible as the server cannot tell the client that there's a new image without the client actually requesting data from the server. You'd need to change the javascript of the image field to do some kind of server polling and requesting new images.

Posted

ok, thats something i can live with, thank you.

another question: when using something like $this->message($this->_("blabla...")); in the inputfield module we spoke about, shouldn`t this work?

Posted

Depends on where you're doing this and if you're using SystemNotifications. With the module enabled I had times, where messages invoked shortly before a redirect where gone after the redirect.

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.
×
×
  • Create New...