Jump to content

Can not upload image on a dependent field


Guy Verville
 Share

Recommended Posts

I have set an image field to appear only if another field is checked. This works perfectly. However, when I try to upload an image into that field (image type), nothing happens. There is already another image field in the template. 

I click the field Vedette

post-1691-0-85041900-1394379299_thumb.pn
The image field appears.
post-1691-0-82044600-1394379298_thumb.pn
I select a file. There is no restriction for the size but it is very small.
post-1691-0-33104700-1394379298_thumb.pn
Processwire seems to process the file.
post-1691-0-34141500-1394379297_thumb.pn
Then nada...
post-1691-0-24091400-1394379296_thumb.pn

I did try to upload the same file in the regular image field, and it works perfectly.

Any idea?

post-1691-0-24091400-1394379296_thumb.pn

post-1691-0-34141500-1394379297_thumb.pn

post-1691-0-33104700-1394379298_thumb.pn

post-1691-0-82044600-1394379298_thumb.pn

post-1691-0-85041900-1394379299_thumb.pn

Link to comment
Share on other sites

And this image field does not appear to be sizable by the ->size method... I get this error:

2014-03-09 12:33:24    admin    http://dev.creacc.org/    Error:     Exception: Method Pageimages::size does not exist or is not callable in this context (in /home/creaccor/public_html/dev/wire/core/Wire.php line 320)  #0 /home/creaccor/public_html/dev/site/templates/accueil.php(16): Wire->__call('size', Array) #1 /home/creaccor/public_html/dev/site/templates/accueil.php(16): Pageimages->size('140px', '85px') #2 /home/creaccor/public_html/dev/wire/core/TemplateFile.php(140): require('/home/creaccor/...') #3 [internal function]: TemplateFile->___render() #4 /home/creaccor/public_html/dev/wire/core/Wire.php(359): call_user_func_array(Array, Array) #5 /home/creaccor/public_html/dev/wire/core/Wire.php(317): Wire->runHooks('render', Array) #6 /home/creaccor/public_html/dev/wire/modules/PageRender.module(337): Wire->__call('render', Array) #7 /home/creaccor/public_html/dev/wire/modules/PageRender.module(337): TemplateFile->render() #8 [internal function]: PageRender->___renderPage(Object(HookEvent)) #9 /home/creaccor/public_html/dev/wire/core/Wire.php(359): call_user_func_array(Arra
 
This is restricted to one occurrence, but I did try to set no limit. Same problem.  The code is simple, and works with the regular image.
 
			$lesVedettes = $pages->find('vedette=1'); 
			$itemVedette = 0;
			$miniatures = '<div id="lesMiniatures" class="grid-35 mobile-grid-100 tablet-grid-35"><ul class="ui-tabs-nav">';
			$photos = '<div id="lesPhotos" class="grid-65 mobile-grid-100 tablet-grid-65">';
			foreach ($lesVedettes as $vedette){ 
					$itemVedette++;
				  $miniatures .= '<li class="ui-tabs-nav-item" id="nav-fragment-'.strval($itemVedette).'">';
					$miniatures .= '<a href="#fragment-'.$itemVedette .'">';
					$miniatures .= retournerImage($vedette->imagevedette->size('140px','85px')->url);

Link to comment
Share on other sites

I have read the document and it doesn't help. My field is called imagevedette (which is of an image type). I have also the regular image field (two purposes here, i must separate those fields for the user).  if i call imagevedette->url, I get the path, but no image. Something eludes me here...

Further investigation.

1. I have two image fields, one called images and the other one called imagevedette. The former has no restriction, the latter  is limited to 1 occurrence.

2. This code :     echo $vedette->images->eq(0)->url outputs this: /site/assets/files/1001/montreal_en_rose.png

3. This code :     echo $vedette->imagevedette->url outputs this: /site/assets/files/1001/

Perhaps we can't have two image fields in the same template?

Link to comment
Share on other sites

Also do you have output formatting set to false at some point? It makes single image fields behave as arrays too.

if you add the eq(0) to imagevedette field too, the url method will work.

There are no restrictions for the amount of image fields in template.

Link to comment
Share on other sites

Hello Horst,

I have tried that, and it didn't help. I used a workaround in the meantime, just uploaded the photo and used CSS to resize it. When I will have time, I will try to figure out what's going on.



Thanks Apeisa for the input, but I have tried this too. Very strange.

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...