Jump to content

Process Module: Uploading an Image


Orlando Hamsho
 Share

Recommended Posts

My question:

How do I make a proper Image field in a process module?

The situation:

I'm making a process Module that requires you to upload an image.

The problem:

I can't seem to be able to save images through my process Module image Field. To further explain:

  • The loading animation (pink bar filling up to 100%) doesn't trigger.
  • When trying to save the page, I get sent to an error each time (which i've been slowly debugging), current one is:

Error: Call to a member function first() on a non-object (line 435 of [path-to-wire-folder]/modules/Inputfield/InputfieldFile/InputfieldFile.module) 

This error message was shown because you are logged in as a Superuser. Error has been logged.

Which currently corresponds to this code segment:

//InputfieldFile Module
//___processInputAddFile() function

if($this->maxFiles == 1 && $total) {
   $pagefile = $this->value->first(); // This is the line.
   $description = $pagefile->description;
   $tags = $pagefile->tags;
   $rm = true; 
   if($filename == $pagefile->basename) {
       // use overwrite mode rather than replace mode when single file and same filename
       if($this->overwrite) $rm = false;
   }
   if($rm) {
       if($this->overwrite) $this->processInputDeleteFile($pagefile);
       $this->singleFileReplacement = true; 
   }
} 

I also can't seem to find examples of how to do this in the existing modules (The MarkUpSEO one, for example, uses an URL field that it later processes on it's own).

My code:

// Image Field 
array(
'name' => 'example_image', // name of field
'type' => 'image', // type of field (any Inputfield module name)
'label' => $this->_('Example Image Field'), // field label
'description' => $this->_('Example Image Field'), 
'required' => true, 
'maxFiles'=> 1,
'destinationPath' => wire('config')->paths->ProcessExample."assets"
)

The destinationPath i'm choosing is a folder named "assets" inside of my own module, but apparently there's something i'm missing to make it work.

Thanks in advance for any help you can provide on this topic :)

Link to comment
Share on other sites

  • 1 year later...

Sorry for rising this topic from the dead, but I'm facing the same problem currently. I would like to add a custom option to a module, which allows to upload an image. Since a module is not a page, you simply can't bind an image to a module, I guess. Is that assumption right?

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