Author Topic: a bug (?) in function random_cat_image_file ?  (Read 6435 times)

0 Members and 1 Guest are viewing this topic.

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
a bug (?) in function random_cat_image_file ?
« on: December 12, 2002, 08:36:12 AM »
if u use this function in category_bit.html template (already there, need just uncoment it)
Code: [Select]
      {if random_cat_image_file}<a href="{cat_url}"><img src="{random_cat_image_file}" width="{width_limited50}" height="{height_limited50}" border="1"></a>{endif random_cat_image_file}

it will show 404 picture if thumnbnail is media image...

while I was writing this, I figured where is the problem. here is the fix for it:
in /includes/functions.php file search for:
Code: [Select]
     return get_file_path($random_image_cache[$category_id]['image_thumb_file'], "thumb", $category_id, 0, 1);
change to this:
Code: [Select]
    if (!get_file_path($random_image_cache[$category_id]['image_thumb_file'], "thumb", $cat_id, 0, 0)) {
      $file_src = ICON_PATH."/".get_file_extension($random_image_cache[$category_id]['image_media_file']).".gif";
    }
    else {
      $file_src = get_file_path($random_image_cache[$category_id]['image_thumb_file'], "thumb", $cat_id, 0, 1);

   }
      return $file_src;
should work now.  :wink:  :D
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
a bug (?) in function random_cat_image_file ?
« Reply #1 on: December 15, 2002, 08:47:44 PM »
Can someone help me?
I'm trying figure out how {if random_cat_image_file} works...
I mean, when this calls from templates and there is no images in the category, it wont display anything...but I'd like it display "noimage.gif" image.
I tryed change in functions.php
Code: [Select]
   if (defined("SHOW_RANDOM_IMAGE") && SHOW_RANDOM_IMAGE == 0 || defined("SHOW_RANDOM_CAT_IMAGE") && SHOW_RANDOM_CAT_IMAGE == 0) {
      $random_cat_image_file = "";
    }
    else {
      $random_cat_image_file = get_random_image($category_id, 0, 1);
    }
to this:
Code: [Select]
   if (defined("SHOW_RANDOM_IMAGE") && SHOW_RANDOM_IMAGE == 0 || defined("SHOW_RANDOM_CAT_IMAGE") && SHOW_RANDOM_CAT_IMAGE == 0) {
      $random_cat_image_file = get_gallery_image("noimage.gif");
    }
    else {
      $random_cat_image_file = get_random_image($category_id, 0, 1);
    }

and in categories.php
Code: [Select]
$random_cat_image = (defined("SHOW_RANDOM_IMAGE") && SHOW_RANDOM_IMAGE == 0) ? "": get_random_image($cat_id);
to this:
Code: [Select]
$random_cat_image = (defined("SHOW_RANDOM_IMAGE") && SHOW_RANDOM_IMAGE == 0) ? get_gallery_image("noimage.gif") : get_random_image($cat_id);

no effect...
can someone help me with this?
thx.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
a bug (?) in function random_cat_image_file ?
« Reply #2 on: December 15, 2002, 09:28:17 PM »
It seem this thread is only for my questions/answers...and I should give myself 24hours before post a question...
again solved this one too:
in functions.php without changes above, search for
Code: [Select]
     return get_file_path($random_image_cache[$category_id]['image_thumb_file'], "thumb", $category_id, 0, 1);
    }
  }
}
change to:
Code: [Select]
     return get_file_path($random_image_cache[$category_id]['image_thumb_file'], "thumb", $category_id, 0, 1);
    }
  }elseif ($return_file) {
      return get_gallery_image("noimage.gif");
 }
}

if with changes above, search for:
Code: [Select]
     $file_src = get_file_path($random_image_cache[$category_id]['image_thumb_file'], "thumb", $cat_id, 0, 1);

   }
      return $file_src;
    }
  }
}
change to this:
Code: [Select]
     $file_src = get_file_path($random_image_cache[$category_id]['image_thumb_file'], "thumb", $cat_id, 0, 1);

   }
      return $file_src;
    }
  }elseif ($return_file) {
      return get_gallery_image("noimage.gif");
 }
}
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline wh-em

  • Newbie
  • *
  • Posts: 17
  • إمبراطورية وحيد ، أكبر دعم عربي للسكريبت 4images
    • View Profile
    • إمبراطورية وحيد
Re: a bug (?) in function random_cat_image_file ?
« Reply #3 on: June 15, 2008, 06:17:09 PM »
thank you ...
I have the same proplem in 1.7.6
but it fixed wirh your Solution

thank you :)