When I create an image ad, it's set by default as Pending. If I try to change it directly from Pending to Active, when I save it I get the following error:
Image validation failed, unable to mark ad as active. Setting ad as pending. If you do not see any more errors, you should now be able to set your ad as active.

I can set it to Approved successfully, but when I try to change it from Approved to Active, I get the same error and the ad reverts to Pending status.

I'm working as an admin user, with all permissions turned on. I can work with text ads correctly. The error happens with both .gif and .png ads, which are created in Photoshop... so what is "image validation" and why doesn't it like them?

CommentFileSizeAuthor
#8 153319.patch899 bytesowen barton
NYT_184x90_450_rgt.png6.14 KBadam_b

Comments

jeremy’s picture

This is a known issue which I've not had time to debug. At this time I'm unsure why some people have this problem intermittently, and other people have the problem all the time. I'm currently traveling, but once I settled down in early July I plan a complete rewrite to introduce new functionality that I require, and will address this bug at that time. Of course, anyone that's able to debug the problem before that please feel free to submit a patch.

adman4054’s picture

Just FYI. I 'm using Drupal 5.x and downloaded the "ad module" for this version. The 5.x version and the 4.7 seem to be the same. I noted that on the "install.txt" of the 5.x version it says 4.7, maybe wrong download?

jeremy’s picture

The 4.7 version of the ad module wouldn't work at all on Drupal 5.x. The version reference in the INSTALL.txt file was fixed after 1.1 was released.

yodersj’s picture

I was getting this same issue until I created an Ad group and selected it for my ad. It appears if you select the "<none>" option it becomes unselected. At least that's my observations. Sometimes I'll still get that image validation failed when an ad group is selected, but not every time.

Note: I'm using 4.7.x, but the "fix" could be the same for 5.1.x. Of course, now I'm seeing something like this bug.

adman4054’s picture

That fix worked for me on 5.1

jeremy’s picture

Thanks yodersj. Indeed, it becomes easy to duplicate this problem when there are no ad groups. That should make it easy to track down and fix. Unfortunately I'm mid-route in my travels, but within a week I'll be settled down and will address this bug.

In the mean time, people wanting to work around this problem should try creating an ad-group and assigned their ad to that group.

Andreas Wolf’s picture

The bug is in function ad_image_validate_size($file, $nid) {

    $terms = module_invoke('taxonomy', 'node_get_terms', $nid);
    foreach ($terms as $tid => $term) {

No terms -> no foreach -> function returns false -> ad_image_load_image returns false -> ad_image_adapi throws "Image validation failed, unable to mark ad as active."

Btw. setting a term AND marking the ad as active does not work. You have to set a term, submit and then mark the ad as active.

owen barton’s picture

StatusFileSize
new899 bytes

Here is a patch that makes this work even when to group is selected (or even created). It's slightly hacky, in that it just creates a single NULL array element if the array is empty to ensure that it goes into the foreach and gets the default image settings - ad_image_format_load() is designed to accept a NULL value anyway, so this is not massively out of line.
If we wanted to do this a somewhat cleaner way we could move the guts of the foreach to another function and then call in once if there are no terms, or through the foreach if there are terms.

owen barton’s picture

Status: Active » Needs review
jeremy’s picture

Status: Needs review » Reviewed & tested by the community

This will work for now. I'm planning a rewrite of the image_module which will change a lot of this handling (decoupling it from the upload module, among other things), so for now we just need it to work.

I'm planning to make a run through the issue queue next week, and will merge this patch at that time, among others.

fufi’s picture

In case anyone else had the same issue, i still couldn't activate an ad after adding it to a group, but then i set it to Approved first, and then Active, and it worked

jeremy’s picture

Status: Reviewed & tested by the community » Fixed

Patch committed. Thanks! :)

welsh’s picture

I am still having problem despite the patch and workaround. I am getting error messages such as "Unable to locate image c:\windows\temp\tmp14E.tmp" even though the temporary file exist. I am running Drupal on IIS. Does anybody know if I have to set any security settings on the temporary directory?

jeremy’s picture

Welsh, your problem is with the configuration of IIS and the upload module, not the ad module. Try searching the support forums, mailing list archives, etc -- I have no experience with IIS and the upload module. You might start with this comment, found with a google search.

Anonymous’s picture

Status: Fixed » Closed (fixed)
hyperart’s picture

The problem seems to be with the default "ad owner" permissions after you add an ad.

Within an ad's settings, go to "ad owners", and then "admin's permissions", you will see that by default not all the permissions are checked. You'll want to be sure to check "manage active ad". After that, you should be able to set your ad as active.

At least this has been working for me. I don't know why the ad owner wouldn't have these permissions ON by default...but looks like changing it makes it all work.

jmlavarenne’s picture

Even with the permission to manage own ads I still get the same issue.

rmjackson’s picture

Version: 5.x-1.1 » 5.x-1.x-dev

I'm getting the same problem: "Image validation failed, unable to mark ad as active. Setting ad as pending." Using the recent 5.x-1.x-dev version on 5.1. I'm just downright perplexed.

dtj’s picture

Under the "File attachments" section of the ad, click the "List" checkbox. That fixed it for me.

jefftrnr’s picture

be SURE you upload image advertisements to "File attachments", not to "Attached Images", if they both exist. This fixed it for me.

kompatv’s picture

Component: ad.module » ad module

I was able to fix this error by unselecting "Promote to Front Page"