Jump to content

Still can't delete image via API. What's wrong??


thomas
 Share

Recommended Posts

Hello,

I have an imagefield set to limit=1 and I try to replace this image via the API:

$video->of(false);
$video->teaserbild->removeAll();
$video->save();

$video->teaserbild = 'http://new_image.jpg';
$video->save();

The result in the admin is a broken image (missing file) as the first image (which was supposed to be removed) and the new one intact as second.

I'm on PW 2.3.0. 

I've had this problem for a while and can't seem to solve it. Can someone help?

Thanks,

thomas

Link to comment
Share on other sites

Hi Adrian,

thanks for the tip but unfortunately it doesn't change anything. I ran 

$video->of(false);
$video->teaserbild->deleteAll();
$video->save();

$video->teaserbild = 'http://new_image.jpg';
$video->save();

on a page with one image already uploaded and got this error:

<b>Warning</b>: unlink(/www/htdocs/v133155/bigair2/site/assets/files/51666/img_20131001_110155.jpg) [<a href='function.unlink'>function.unlink</a>]: No such file or directory in <b>/www/htdocs/v133155/bigair2/wire/core/Pagefile.php</b> on line <b>304</b><br />

and the result remains the same: 

post-605-0-27612100-1381149074_thumb.png

(with the second one being the new one and the first (upper) one being the one that supposedly couldn't be deleted ...)

Any hints?

Thanks,

thomas

Link to comment
Share on other sites

Is it possible that error is still there as a result of previous issues? I am wondering if the image is still in the field_images DB table, but not on the filesystem. I would try removing it from the database and see if that resets things.

Link to comment
Share on other sites

I'm not aware of any bugs here, and I do these kinds of API replacement of images daily. But you might try and see if using the dev branch makes any difference here. Also it would be good to know of any modules you have installed in case anything is hooking into any of this. 

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