Download & Extend

Integrate ad_image with imagecache

Project:Advertisement
Version:6.x-2.x-dev
Component:ad_image module
Category:feature request
Priority:normal
Assigned:Unassigned
Status:needs review

Issue Summary

Hello,

On my Drupal site I currently use the private file system option as I have members-only content that they pay for.. I essentially wanted to show ads to those who were not paid members (not logged in). But I noticed because I have the private file system in place, the ads don't display for anonymous users. Is there anyway to get around this? Perhaps having the upload form on the ad content type upload to a different place?

Thanks in advance!

-Ram0135

Comments

#1

Status:active» postponed (maintainer needs more info)

It's been a long time since I tested private filesystems, but they worked way back. Are you sure you've enabled proper ad module permissions for anonymous users to see advertisements? Please follow the directions in DEBUG.txt and post the output here.

#2

Status:postponed (maintainer needs more info)» fixed

No updates, closing. Re-open with answers to the questions if still an issue.

#3

Category:support request» bug report
Status:fixed» active

Not sure if this needs reopening, but I wanted to put my voice in.

I have a site that requires having private downloads *on* to keep anonymous users out of attachments, but this also prevents me from turning "view downloads" on for anonymous users so they can see the ads.

In effect, only logged-in users can view ads. Is there any tip/trick to get anonymous users to view ads, without showing all attachments/uploads to everyone?

Thanks for all you hard word on this module - aside from this one issue, it so rocks.

#4

A way around this is to use the imagecache module to render ad images. However, to do this, I had to patch ad_image to introduce a theme function for the ad image rendering (see #298608: Create theme function for ad_image rendering ).

This works because the imagecache module does not check the permissions of the module used to upload the image, only its own per-preset permissions. I can use the upload (or ad_image) module to upload an image. Even if "view uploaded files" is FALSE for anonymous users, if I set "view imagecache [preset]" to TRUE for anonymous users they will be able to access the file through a URL such as system/files/imagecache/[preset]/[filename].

Another big advantage of using imagecache is that it takes care of serving up the last modified headers, and responding to browsers who submit this header. This makes the caching of ads possible, and saves a whole lot of bandwidth.

Note, there is a gotcha. Imagecache actions break animated gif files (removing all frames except the first one). I have submitted a patch for the imagecache module at #298555: Prevent any image manipulation where a preset has no actions that allows presets with no actions to bypass image processing completely, leaving animated gifs intact.

BTW, my theme function using imagecache (dependent on the patch in #298608: Create theme function for ad_image rendering ) looks like this:

function phptemplate_ad_image_image($path, $alt = '', $title = '', $attributes = NULL, $getsize = TRUE) {
  if (!$getsize || (is_file($path) && (list($width, $height, $type, $image_attributes) = @getimagesize($path)))) {
    $attributes = drupal_attributes($attributes);
    // Use 'banner' imagecache preset to render image
    $url = preg_replace('&'. drupal_get_path('module', 'ad') .'/&', '', imagecache_create_url('banner', $path));
    return '<img src="'. check_url($url) .'" alt="'. check_plain($alt) .'" title="'. check_plain($title) .'" '. $image_attributes . $attributes .' />';
  }
}

#5

Title:Use module with private filesystem?» Integrate ad_image with imagecache
Version:5.x-1.x-dev» 6.x-1.x-dev
Category:bug report» feature request

Updating this issue to instead request that ad_image be optionally integrated with imagecache.

#6

It is now possible to integrate the ad module with the imagecache module as described in comment #4 in this issue as this patch has landed: #298608: Create theme function for ad_image rendering .

I would like to see integration built in if the imagecache module is enabled, so leaving this issue open for possible future development.

#7

Version:6.x-1.x-dev» 6.x-2.x-dev

Moving to the 6.x-2.x branch where current development is happening.

#8

very interested in this. subscribing.

Will the theme function above work with the latest version of ad module?

is there another way to link imagecache and ad? I haven't seen it.

#9

Imagecache is now in core, so there's much more incentive for adding this functionality to the ad module:
http://drupal.org/cvs?commit=240506

#10

Attached are some patches that enable imagecache for this module. There are a few difficulties I came across:

* theme('imagecache'...) behaves incorrectly when generating path names when it is called from serve.php
* At the image render level there is no way of knowing which adgroup this image is being rendered for
* There is no nice way to save extra data about an ad group (eg the imagecache preset) so I have used a variable to do this.

AttachmentSize
image.patch 3.4 KB
ad.admin_.inc_.patch 1.56 KB

#11

Subscribe

#12

Status:active» needs review

#13

Subscribe

#14

Subscribe

#15

subscribing

#16

Patch from #10 does not work, at least not with current dev. Theme function from #4 works with a minor change so that width and height is based on imagecache URL and not original image path.

<?php
function cmt_ad_image_image($path, $alt = '', $tooltip = '', $attributes = NULL, $getsize = TRUE) {
  if (!
$getsize || (is_file($path) && (list($width, $height, $type, $image_attributes) = @getimagesize($path)))) {
   
$attributes = drupal_attributes($attributes);
   
// Use 'banner' imagecache preset to render image
   
$url = preg_replace('&'. drupal_get_path('module', 'ad') .'/&', '', imagecache_create_url('banner', $path));
    list(
$width, $height, $type, $image_attributes) = @getimagesize($url);
    return
'<img src="'. check_url($url) .'" alt="'. check_plain($alt) .'" title="'. check_plain($title) .'" '. $image_attributes . $attributes .' />';
  }
}
?>

#17

subscribing

#18

i do #10 but image cannot display