Websnapr has upgraded it's code. Therefore, the module shows only one image with the hint "Please update your websnapr code".

http://www.websnapr.com/code/

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Dane Powell’s picture

Priority: Normal » Critical

sub- websnapr_field is completely useless until this is resolved.

gzett’s picture

The problem with the new Websnapr code is, that they are using javascript. The javascript file must be loaded from websnapr, because they are using a hash code, to check the age of the file. But Drupal 6 does not support external js-files.

I have a suggestion for the problem:

--- websnapr_field.module.org   2011-08-09 16:39:52.000000000 +0200
+++ websnapr_field.module       2011-08-11 00:56:00.000000000 +0200
@@ -77,6 +77,8 @@
  *
  */
 function theme_websnapr_field_formatter($element) {
+  $external_js = 'http://www.websnapr.com/js/websnapr.js';
+  drupal_add_js('document.write(unescape("%3Cscript src=\''. $external_js . '\' type=\'text/javascript\'%3E%3C/script%3E"));', 'inline');
   if ($element['#item']['url']) {
     return websnapr_field_field_formatter($element['#field_name'], $element['#item'], $element['#formatter'], $element['#item']['url'], $element['#node']->title);
   }
@@ -101,9 +103,7 @@
   }
   $key = variable_get('websnapr_account_key', '');
   if ($key) {
-    $websnapr_url = 'http://images.websnapr.com/?size='. $size .'&key='. $key .
-      '&url='. urlencode($item['query']? $url.'?'.$item['query']: $url);
-    $image = theme('image', $websnapr_url, $title, $title, array('height' => $height, 'width' => $width), FALSE);
+    $image = '<script type="text/javascript">wsr_snapshot(\'' . $url . '\', \'' . $key . '\', \'s\');</script>';
     return l($image, $url, array('html' => TRUE, 'attributes' => $item['attributes'], 'query'=> $item['query']));
   }
 }
jvinci’s picture

following

queryblitz’s picture

+1

monstordh’s picture

Has anyone used this code? Does it resolve the issues with the new code without any problems?

discipolo’s picture

indeed, it works

discipolo’s picture

Status: Active » Needs review
FileSize
1.19 KB

reuploading as patch

Dane Powell’s picture

Version: 6.x-1.2 » 6.x-6.x-dev
Status: Needs review » Needs work

Are you guys aware that this has already been "fixed" in dev? See #1062678: new websnapr code

Note that they take a rather different approach to solving this there- loading the script on hook_init(). I think the approach in #7 is probably better as it doesn't use hook_init(), but I'm not sure. Thoughts?

Note that the patch in #7 is not a valid Git patch and needs to be re-rolled WRT 6.x-dev regardless.

discipolo’s picture

try of reroll

Dane Powell’s picture

Status: Needs work » Needs review
FileSize
1.74 KB

Okay, here's a patch WRT HEAD. It adopts the 'meat' of the code added by the other issue, #1062678: new websnapr code, but removes the hook_init() and replaces it with the drupal_add_js() proposed in #9. I've tested it and it seems to work fine.