I am able to create an image ad in the default group but it will not display on the front end. Additionally, i get this error message when i view the edit screen in the admin:

* warning: imagejpeg() [function.imagejpeg]: Unable to open 'files/preview/d04310708dd997a47cd4b819f491862a.jpg' for writing: No such file or directory in /home/.preacher/sportsbiz/drupal/includes/image.inc on line 321.
* The selected file files/warsaw.jpg could not be uploaded, because the destination is not properly configured.

Any help would be appreciated.

Comments

jeremy’s picture

Perhaps review this thread which discusses a similar problem. It sounds like you've got a permissions problem...

jeremy’s picture

Component: ad.module » ad_image.module

You may also want to review this link which offers a lot of information that you might find helpful.

(I found both of these links with a quick Google search...)

jdblank’s picture

Thanks for the links. Unfortunently that did not solve my problem. My banner infact is being uploaded despite the error message.

However it won't display. When i view source of a page that should display the banner I notice this tag:

There is nothing in the src="" I am wondering if that is the problem.

jeremy’s picture

Are you using the public or private download method?

Does this problem only happen when using the development branch? ie, do you have the same problem with the last stalbe release, 5.0-1?

As you're testing the development tree, please install the latest version then do a view source of your webpage and find the adserve.php link, then copy that url into your browser, adding a &debug=2 at the end and post the resulting output here.

jdblank’s picture

I am using the public method for files to download. Here is the debug output. I installed the latest dev version.

------

ad_dir: '/home/.preacher/sportsbiz/drupal/sites/all/modules/ad'
debug: '2'
cache: 'none'
nids: ''
tids: ''
hostid: ''
quantity: '1'
Root drupal directory detected as '/home/.preacher/sportsbiz/drupal'.

/home/.preacher/sportsbiz/drupal/sites/all/modules/ad/adserve.php: // $Id: adserve.php,v 1.2.2.15.2.15 2007/05/23 14:54:20 jeremy Exp $
/home/.preacher/sportsbiz/drupal/sites/all/modules/ad/ad.module: // $Id: ad.module,v 1.2.2.29.2.27 2007/05/24 16:32:04 jeremy Exp $

No cache enabled.
Drupal bootstrap '7'.
ad:

stdClass Object
(
[aid] => 1012
[adtype] => image
[redirect] => http://beta.sportsbusinessradio.com/ad/redirect/1012
[activated] => 1180071503
[maxviews] => 0
[maxclicks] => 0
)

Loading module 'sites/all/modules/ad/image/ad_image.module'.
Ads displayed: 1
document.write('
');

jeremy’s picture

I do not see any ad module code on the website http://beta.sportsbusinessradio.com/. How are you trying to display ads? Also, have you configured proper permissions? Please review the INSTALL and README files that are included with the module to be sure you have followed all directions there.

jdblank’s picture

I have followed all of those instructions.

When I view source I see ad info towards the bottom of the page:

jeremy’s picture

It looks like your posting got cut off. If you were trying to post html, wrap it in <code></code> tags so that Drupal.org doesn't strip it.

I stand corrected, there is ad information on that page -- but ads are not showing because permission was not granted. This is what I see:

<div class="advertisement" id="group-none"><!-- Enable 'show advertisements' permission if you wish to display ads here. --></div>
jdblank’s picture

When you say permission do you mean the access control permission because have show ads checked for anonymous users. Or do you mean some other permissions.

Here is what I see at the bottom of the homepage:

		
<div class="advertisement" id="group-"><script type="text/javascript" src="http://beta.sportsbusinessradio.com/sites/all/modules/ad/adserve.php?q=1&amp;t=2"></script></div>
	</div>
jdblank’s picture

I think something might be wrong with the ad group. I created a group called sponsors but the code does not indicate that group.

jdblank’s picture

Ok, i deleted my original ad (the only one i had in the system) and recreated it.

The ad still does not show but there is much more code now:

<div class="sidebar-block">
	<h1>All active Sponsors group ads</h1>
	<div class="sidebar-text">
		<div class='view view-active-Sponsors-group-ads'><div class='view-content view-content-active-Sponsors-group-ads'>
<div class="advertisement" id="group-4,6,8,11,13,14,15,16,17,18,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,36,46,47,49,50,51,52,53,55,56,57,58,59,60,61,62,64,65,66,67,69,70,71,72,73,74,75,76,77,78,79,80,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,112,113,114,115,116,117,118,119,120,121,122,123,124"><script type="text/javascript" src="http://beta.sportsbusinessradio.com/sites/all/modules/ad/adserve.php?q=1&amp;n=4,6,8,11,13,14,15,16,17,18,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,36,46,47,49,50,51,52,53,55,56,57,58,59,60,61,62,64,65,66,67,69,70,71,72,73,74,75,76,77,78,79,80,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,112,113,114,115,116,117,118,119,120,121,122,123,124"></script></div>
</div></div>
	</div>
</div>	
		</div>
jeremy’s picture

You are currently trying to use views to select ads -- that's more complicated. I would suggest first start with the default blocks provided by the module and confirm that it works for you first. Only then should you navigate your way into something more complex.

In your first example, t=2, this was a taxonomy based block. But there are no ads assigned to term id 2:

term is 2

The second is node based, but again there are no ads that are assigned to these nodes:

nodes

With a little experimentation, I see that your ad is assigned a tid of 6:

term is 6

So, build a block that displays ads with a tid of 6, and you will see your ad.

jdblank’s picture

OK, I switched it to the default ad group and now i see some code that it looks like it should all work but it still does not display.

Josh

BTW - Thanks for all your help!

jeremy’s picture

When I manually try the adserve url that's in your page source, it works fine. But as with you, I don't see it on your page. I don't see any obvious reason for this.

I do see that adserve.php is pointing to www.sportsbusinessradio.com, not beta.sportsbusinessradio.com. Is that intentional?

jdblank’s picture

yeah, we are no longer in beta any more and moved the site to live.

jeremy’s picture

Title: Ads Not showing » module sets some images with 0 height and 0 width causing them to not display
Assigned: Unassigned » jeremy
Category: support » bug

I think I duplicated your problem on my test website. Somehow I managed to upload an image ad and confuse the ad_image module into thinking that the image was of 0 height and 0 width. The simplest solution is to just edit the ad -- save it (without even making changes) and it should recalculate the image size. Once it does that, I'd expect it to start showing up again.

(However I see that now there are no ads in the default group that you're trying to display on the beta site -- perhaps you disabled it.)

I will fix this bug, but please confirm that this is indeed the problem you are having. (I'm changing the title as I'm relatively confident this is your problem.)

jdblank’s picture

That is exatly the problem. Made my ad active and it now has a image height and width of 0. Editing and saving does not fix this for me on Mac FireFox.

jpsalter’s picture

I had the same problem and did not want to figure out why images were 0 x 0. So, I edited the ad_image.module function ad_image_display and removed the code that inserts the height and width:

function ad_image_display_ad($ad) {
  $image = db_fetch_object(db_query('SELECT a.fid, a.url, a.tooltip, a.width, a.height, f.filepath FROM {ad_image} a INNER JOIN {files} f ON a.fid = f.fid WHERE a.aid = %d AND f.nid = %d', $ad->aid, $ad->aid));
  // Strip module path from image path if serving images from adserve.php.
  $image_path = preg_replace('&'. drupal_get_path('module', 'ad') .'/&', '', file_create_url($image->filepath));
  $target = variable_get('ad_link_target', '_self');
  return ("<div class=\"image-advertisement\" id=\"ad-$ad->aid\"><a href=\"$ad->redirect/@HOSTID___\" target=\"$target\" title=\"". htmlentities($image->tooltip, ENT_QUOTES) ."\"><img src=\"$image_path\" /></a></div>");
}
jeremy’s picture

I'm not sure why this problem is consistently happening for you -- I've only had it happen once and was not able to duplicate it again.

Does the problem also happen with Safari? I doubt it's a Mac-specific bug, but it's worth checking.

Adding logic to prevent the activation of ads with a 0 size is simple, but it sounds like that won't be enough to fix your problem. I do intend a major rewrite of the ad_image module in the relatively near future, perhaps during that rewrite I will fix your problem.

fax8’s picture

Actually I have exactly the same issue here and this is also a problem for my work on the flash plugin.
I don't think that this is an issue with the browser but something related to the module logic. I've been able to reproduce this on Firofox and Konqueror both on Linux.

Unfortunately, even if I spent a reasonable amount of time on this issue, I still not been able to figure out what is happening here.

Have a look at my ad_image table:

+-----+-----+--------------------------+-----------+-------+--------+
| aid | fid | url                      | tooltip   | width | height |
+-----+-----+--------------------------+-----------+-------+--------+
|  14 |   0 | http://www.varesano.net/ | fsfsdfsdf |     0 |      0 |
|  15 |  23 | http://www.varesano.net/ |           |     0 |      0 |
|  18 |   0 | http://www.varesano.net/ |           |     0 |      0 |
|  23 |   0 | http://www.varesano.net/ | ciao      |     0 |      0 |
|  36 |   0 | http://www.varesano.net/ |           |   337 |    308 |
|  37 |   0 | http://www.varesano.net/ |           |     0 |      0 |
|  38 |  79 | http://www.varesano.net/ | fsdf      |     0 |      0 |
|  39 |   0 | http://libero.it/        | fsdf      |   540 |    720 |
+-----+-----+--------------------------+-----------+-------+--------+

You can see that the size fields are sometimes empty, same for the fid.

Something is wrong with the image validations functions and the image loading ... but I wasn't able to fix this.

I can give you access to the server where I'm having this issues, just contact me.

jeremy’s picture

I have added code to prevent image ads from being saved if they have a 0 size. This should prevent the confusion of ads not displaying properly, but will of course cause frustration for people that are affected by this bug -- hopefully they will step up and help better debug this problem.

Code was added to both the 4.7.x and 5.x development trees.

However, this bug still exists so I am not closing this issue.

awizon’s picture

I downloaded the ad-5.x-1.1.tar.gz module and installed it. I am using Firefox 2.0.0.3 on a MacBook Pro and the ad displays when I am logged in as the administrator, but does not display otherwise. I checked the logic in Drupal for users that can see the ad and no boxes are checked. I believe this is the same problem discussed above. I am new to Drupal, but have done a lot of work with it in a short time (no programming changes though!). Is there a fix that I missed?

awizon’s picture

My bad, I needed to active advertisement permissions in the User Management page. Sorry about that.

ryo’s picture

Subscribing

tic2000’s picture

Title: module sets some images with 0 height and 0 width causing them to not display » Upload Preview

The error message in the first post of this issue is generated bu Upload Preview module. Try to disable that module and see if it solves your problem.

tic2000’s picture

Title: Upload Preview » module sets some images with 0 height and 0 width causing them to not display
rbottoms’s picture

Hi, has someone fixed this problem? I see it's been discussed for weeks. I do understand PHP, but frankly all I want to do is download the module and use it to put ads on my site not debug code that people who are better programmers than me can't fix. How about adding two fields where I tell the module the size of my ad?

I am amazed that this is the only module that sorta kinda works in 5.xxx. Wouldn't the ability to run ads on Drupal sites be a #1 priority someplace? Hell this is the type of thing I'd pay money for.

jeremy’s picture

The problem is not fixed, primarily because I'm unable to consistently duplicate it. I've randomly hit upon it once or twice, but being unable to consistently duplicate it makes it rather difficult to fix. If I found a way to consistently duplicate it, it'd be fixed.

If you're unable to help debug the problem, you could try undoing this change, and then modify the ad_image_display_ad function to not set the height and width. It doesn't bring us any closer to a real solution, but would get you up and running.

jeremy’s picture

As reported here, the bug seems to be tied to not having defined any ad groups. Now knowing how to consistently duplicate the problem, a fix should be forthcoming (once I'm not traveling).

In the interim, you should be able to work around the problem by creating an ad group, and assigning your image ads to that ad group.

owen barton’s picture

I just posted a patch over at http://drupal.org/node/153319 for the case of this error occurring when there are no group terms selected (e.g. on a clean install).

I'll leave this open in case there are other situations (e.g. messed up image processing) that are causing this problem.

jeremy’s picture

Status: Active » Fixed

Believed fixed in this issue in the development tree.

Anonymous’s picture

Status: Fixed » Closed (fixed)