rst

image doesnt save

Recommended Posts

Hello,

I have repeater field with an image field as one of its fields. It works correctly on all but one templates. I added an image, it shows the image uploading, but then the image just disappears and it doesn't save. What could it be ?

 

Thanks

Share this post


Link to post
Share on other sites

not showing me any errors. also, i just tried adding the image field on its own, and uploading new images are not saving to it either.

 

Share this post


Link to post
Share on other sites

I enabled debugger, and now I see this error when I upload an image

SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data

parseJSON .../wire/modules/Jquery/JqueryCore/JqueryCore.js:2:13582
uploadFile/< .../wire/modules/Inputfield/InputfieldImage/InputfieldImage.js:1450:21

Share this post


Link to post
Share on other sites

Hmm that error means either pw returns empty json or you echo a string somewhere and json becomes invalid. 

On your developer console (F12) activate network tab then try adding an image, inspect the request and response values, check if something weird is going on

Share this post


Link to post
Share on other sites

thing is, it worked for all the other sections, and just today i added a new section and i am having this problem. i didnt change anything in the code

Share this post


Link to post
Share on other sites

similar problems were reported here:

google error-msg site:.processwire.com, e.g.

SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data site:.processwire.com

Share this post


Link to post
Share on other sites

thank you. i looked through some of the similar posts before i posted, didnt help.

will try to google that error message, thanks

Share this post


Link to post
Share on other sites

seems the error is caused by this line, in InputfieldImage.js

var response = $.parseJSON(xhr.responseText),

Share this post


Link to post
Share on other sites

also, just noticed that this error is happening on every single image field now. i can't upload new images to the site.

i didn't make any edits to the server, so not sure why this is happening all of a sudden

Share this post


Link to post
Share on other sites

I've just checked the source for InputfieldImage and it definitely originates from the backend. Somehow along the way json gets corrupted/wrong data is returned. 

You need to check the server response using developer console to get an idea of what it really is. 

https://developers.google.com/web/tools/chrome-devtools/network-performance/reference

Just to cross it off the list, try downloading the latest source from GitHub and replacing /wire/ directory. 

Share this post


Link to post
Share on other sites

hmm, response i get is this

error: false
message : AJAX Page not saved (no changes)

Share this post


Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By derelektrischemoench
      Hi guys,
      I'm trying to resize images which I query through getRandom(). I can't seem to get it right though. What I have so far is:
       
      $randomImage = $pages->get($targetPageId)->images->getRandom() Which returns an image, albeit in original resolution. I assumed I should be able to call resize() on the image like so:
      $randomImage = $pages->get($targetPageId)->images->getRandom()->width(400) Which unfortunately gives me an exception. I assume this is because getRandom() might not return an image but something else(?).
      So how would I do this correctly?
       
      Greetings
      derelektrischemoench
       
    • By louisstephens
      Ill be honest, I am a bit unsure how accomplish this. I have a repeater (dev_repeater) that contains an image field set to 1 image. Nested within this repeater, is another repeater (dev_child_repeater) that allows a user to add in some urls. However, there is also a hidden field that I am trying to pass the parent repeater's image path. 
      I know I can output all the data by using:
      <?php foreach($page->dev_repeater as $repeater) { foreach($repeater as $url) { # do some stuff } } ?> For the life of me, I can not figure out how to obtain the image url in my php to pass to a variable inside the nested foreach loop. Hopefully this made some sense.
    • By Xonox
      Hi,
      I have a template that it's working fine in development, however I can't get it to work on production! It shows every information inside repeater fields except the images.
      Here's the template:

      These are the circuit_day_image settings:

      This is the code:
      <?php foreach($page->circuit_days as $circuit_day) { if($circuit_day->circuit_day_image) { $day_image = $circuit_day->circuit_day_image->size(300, 300)->url; echo '<img src="' . $day_image . '" />'; } else { echo 'No image! :('; } echo '<h2>' . $circuit_day->title . '</h2>'; echo $circuit_day->body; } ?> I always get "No image! :("
      I think I'm doing everything right!
      Anyone else with a similar problem?
      Update
      After uploading the production database into my server, the images stopped working. It can be one of two problems:
      1. Bad field configuration;
      2. Something wrong with the Database.
      I can't find the problem. Any suggestion is welcome, thanks,
      Update 2
      I forgot to upload the images. It's working on dev and not on production. Still no clue!
      Clue 1
      When I insert
       <pre><?php print_r($circuit_day); ?></pre>
      On development I get a clean list for each repetition:

      However, on production, the command gets on a weird recursive loop that takes forever (it even slows the browser to a halt):

      What might be going on?
    • By Marcel
      Hey, 
      I am very new to processwire and bootstrap. I have a field (text area) and there I want to be able to insert an image which is responsive. I tryed it with Source but in the end the page doesn't seem to like it when I insert in Source the following code
      <img src="<?php echo $homepage->content_img->url; ?>" class="img-fluid" alt="Responsive image"> What can I do to make it possible to insert reponsive images in a text area?
      Thank you in advance.
      Marcel
    • By gonzz
      I'm doing an artist site and they want to be able to upload a large .tiff to their portfolio. I need to keep to a copy of the original file in the server for the art distributers, and of course serve jpg in the web front end.
      I had the idea of extending the file or image upload input so that if the image is tiff, keep it, and also convert it to jpg, so I could access through something like $image->originalUrl or $image->size(100, 100)->url 
      I was wondering if you thought this a good idea, or if i'm over-engineering something that could be done simply. Also, I've never extended an input, so any examples are welcome.
      Thanks!