Jump to content

setAndSave() to Single Image Field


cabrooney
 Share

Recommended Posts

I save an Image from an URL to an image field using setAndSave().
The image field is set to "Single Item (0 if empty)" and "Maximum Files Allowed = 1".

But the line

$page->setAndSave('bild', $imgurl);

uploads the picture and adds it to the existing one. So there are now a growing number of pictures in my "single item" field.

What i expected to happen was, that the new image would overwrite the existing one.

Am i doing something wrong or is there another setting that i missed?

(Sorry if i posted this in the wrong forum.)

Link to comment
Share on other sites

When you add an image via the API rather than via the inputfield you have to do all the work yourself that the inputfield would otherwise do for you. A recent answer to a similar question, which contains a link to some code that might be useful to you:

 

  • 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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...