If I edit an existing image ad, upload a new image, and delete the old image, then submit, the image in view mode is broken. The image file is correctly uploaded, but in view, the image url does not contain the full url to the image, but http://www.blah.com. Looking at the ad_image table, I noticed that the value for fid was set to "0".

I found this old issue, which seems to be related: #237833: After image uploading it has fid=0

In that case, the insert case was changed to use $node->fid instead of $fid.

In 5.x-1.7 of ad_image.module, the update case is still using $fid, which returns "0" when replacing an old image with a new one. Replacing $fid with $node->fid fixes the problem.

To be more clear, replacing this

db_query("UPDATE {ad_image} SET fid = %d, url = '%s', tooltip = '%s', width = %d, height = %d WHERE aid = %d", $fid, $node->url, $node->tooltip, $node->width, $node->height, $node->nid);

with this

db_query("UPDATE {ad_image} SET fid = %d, url = '%s', tooltip = '%s', width = %d, height = %d WHERE aid = %d", $node->fid, $node->url, $node->tooltip, $node->width, $node->height, $node->nid);

Fixes the problem.

I'm sorry, I don't have time to do up a patch right now, but I thought I should post in case anyone else runs into this problem.

Comments

jeremy’s picture

Status: Active » Fixed

Thanks, patch committed:
http://drupal.org/cvs?commit=272272

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.