Missing / in theme img

csc4 - June 25, 2007 - 12:37
Project:IP to Country
Version:5.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:sugree
Status:closed
Description

I've noticed that line 246 in theme_ip2cc_flag:

function theme_ip2cc_flag($co, $addr = '') {
...
  return "<img src=\"$src\" ".drupal_attributes($attribs)." />";

means URLs get generated as relative which causes not found errors for me - I fixed it with:

  return "<img src=\"/$src\" ".drupal_attributes($attribs)." />";

#1

sugree - July 5, 2007 - 14:34
Assigned to:Anonymous» sugree
Status:active» fixed

I fixed this by using `theme_image` instead. Hopefully it works for you.

Index: ip2cc.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/ip2cc/ip2cc.module,v
retrieving revision 1.10.2.5
retrieving revision 1.10.2.6
diff -u -r1.10.2.5 -r1.10.2.6
--- ip2cc.module        12 Apr 2007 03:59:34 -0000      1.10.2.5
+++ ip2cc.module        5 Jul 2007 14:28:50 -0000       1.10.2.6
@@ -1,5 +1,5 @@
<?php
-/* $Id: ip2cc.module,v 1.10.2.5 2007/04/12 03:59:34 sugree Exp $ */
+/* $Id: ip2cc.module,v 1.10.2.6 2007/07/05 14:28:50 sugree Exp $ */

/*
  * "This 'work' uses the IP-to-Country Database
@@ -241,9 +241,9 @@
     $cc = 'unknown';
     $title = (empty($addr))?'unknown':$addr;
   }
-  $src = check_url(drupal_get_path('module','ip2cc') . "/flags/$cc.png");
-  $attribs = array('width' => 14, height => 14, 'alt' => "$cc", 'title' => "$title");
-  return "<img src=\"$src\" ".drupal_attributes($attribs)." />";
+  $path = drupal_get_path('module','ip2cc') . "/flags/$cc.png";
+  $attribs = array('width' => 14, height => 14);
+  return theme('image',$path,$cc,$title,$attribs,FALSE);
}

function theme_ip2cc_ip_flag($addr) {

#2

csc4 - July 8, 2007 - 01:21

Even better solution - thanks.

#3

Anonymous - July 22, 2007 - 01:45
Status:fixed» closed
 
 

Drupal is a registered trademark of Dries Buytaert.