Author Topic: Mod thumbnail_bit customized to videos and photo  (Read 3491 times)

0 Members and 1 Guest are viewing this topic.

Offline jotabonfim

  • Jr. Member
  • **
  • Posts: 67
    • View Profile
Mod thumbnail_bit customized to videos and photo
« on: January 29, 2010, 01:19:03 PM »
Hello good day!

I would like to make an implementation on my site, is a simple change, but as I am not a guy who dominates php, so I ask for help from you all.

The change would be in order to display the thumb within categories.

Example
When I click on the category of videos I'd like 4images exhibited thumbnail_bit_videos the file (for custom sizes of thumbnail videos)

When I click on the category of pictures I'd like 4images exhibited the thumbnail_bit_photos (custom sizes for thumbnail pictures)

Example 2:
If image_media_file =.flv
response.write (thumbnail_bit_videos)
Else
response.write (thumbnail_bit_photos)
End IF


This is possible, or my logic is wrong?

Thank you all if they can help.



//-----------------------------------------------------
I think the change should be on this page.....................................................................................
//--- Show Images -------------------------------------
//--------------------------------------...................---------------
$site_template->register_vars(array(
  "has_rss"   => true,
  "rss_title" => "RSS Feed: ".format_text($cat_cache[$cat_id]['cat_name'], 2)." (".str_replace(':', '', $lang['new_images']).")",
  "rss_url"   => $script_url."/rss.php?action=images&".URL_CAT_ID."=".$cat_id
));

$num_rows_all = (isset($cat_cache[$cat_id]['num_images'])) ? $cat_cache[$cat_id]['num_images'] : 0;
$link_arg = $site_sess->url(ROOT_PATH."categories.php?".URL_CAT_ID."=".$cat_id);

include(ROOT_PATH.'includes/paging.php');
$getpaging = new Paging($page, $perpage, $num_rows_all, $link_arg);
$offset = $getpaging->get_offset();

$site_template->register_vars(array(
  "paging" => $getpaging->get_paging(),
  "paging_stats" => $getpaging->get_paging_stats()
));

$imgtable_width = ceil((intval($config['image_table_width'])) / $config['image_cells']);
if ((substr($config['image_table_width'], -1)) == "%") {
  $imgtable_width .= "%";
}

$additional_sql = "";
if (!empty($additional_image_fields)) {
  foreach ($additional_image_fields as $key => $val) {
    $additional_sql .= ", i.".$key;
  }
}

$sql = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.", "user_name")."
        FROM (".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c)
        LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = i.user_id)
        WHERE i.image_active = 1 AND i.cat_id = $cat_id AND c.cat_id = i.cat_id
        ORDER BY ".$config['image_order']." ".$config['image_sort'].", i.image_id ".$config['image_sort']."

        LIMIT $offset, $perpage";
$result = $site_db->query($sql);
$num_rows = $site_db->get_numrows($result);

if (!$num_rows)  {
  $thumbnails = "";
  $msg = $lang['no_images'];
}
else {
  $thumbnails = "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\">\n";
  $count = 0;
  $bgcounter = 0;
  while ($image_row = $site_db->fetch_array($result)){
    if ($count == 0) {
      $row_bg_number = ($bgcounter++ % 2 == 0) ? 1 : 2;
      $thumbnails .= "<tr class=\"imagerow".$row_bg_number."\">\n";
    }
    $thumbnails .= "<td width=\"".$imgtable_width."\" valign=\"top\">\n";

    show_image($image_row);
    $thumbnails .= $site_template->parse_template("thumbnail_bit");

    $thumbnails .= "\n</td>\n";

    $count++;
    if ($count == $config['image_cells']) {
      $thumbnails .= "</tr>\n";
      $count = 0;
    }
  } // end while

  if ($count > 0)  {
    $leftover = ($config['image_cells'] - $count);
    if ($leftover > 0) {
      for ($i = 0; $i < $leftover; $i++){
        $thumbnails .= "<td width=\"".$imgtable_width."\">\n&nbsp;\n</td>\n";
      }
      $thumbnails .= "</tr>\n";
    }
  }
  $thumbnails .= "</table>\n";
} //end else
$site_template->register_vars("thumbnails", $thumbnails);
unset($thumbnails);
« Last Edit: January 29, 2010, 02:16:25 PM by jotabonfim »

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
Re: Mod thumbnail_bit customized to videos and photo
« Reply #1 on: January 29, 2010, 02:58:26 PM »
try this:
if (in_array(get_file_extension($image_row['image_media_file']), array("flv""wmv")))
{
  
$thumbnails .= $site_template->parse_template("thumbnail_bit_video");
}
else
{
  
$thumbnails .= $site_template->parse_template("thumbnail_bit");
}
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 jotabonfim

  • Jr. Member
  • **
  • Posts: 67
    • View Profile
Re: Mod thumbnail_bit customized to videos and photo
« Reply #2 on: January 29, 2010, 07:08:46 PM »
Vano Hello, thank you again for your great help!

god mod