Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Topics - zhono

Pages: [1]
This is a very simple one. This will allow you to search images by size.

First, use phpmyadmin or similar to run this SQL. Be sure to change 4images_ to your prefix if you used something else.
Code: [Select]
ALTER TABLE `4images_images` ADD `image_width` INT( 10 ) UNSIGNED NOT NULL DEFAULT '0',
ADD `image_height` INT( 10 ) UNSIGNED NOT NULL DEFAULT '0'

Then in /admin/plugins create an empty file called set_sizes.php and paste inside:
Code: [Select]
/* Created By Zhono */
$root_path = (false === stristr($_SERVER['PHP_SELF'], "/plugins/")) ? "./../" "./../../";


$site_db = new Db($db_host$db_user$db_password$db_name) OR die("HAHAHAHAHA! You Fail At Life!");

$sql "SELECT image_id, cat_id, image_name, image_media_file, image_keywords, image_width, image_height 
        FROM "
        WHERE image_width = '0'
        OR image_height = '0'"

$result $site_db->query($sql);


$worknum 0;

while (
$row $site_db->fetch_array($result)){
$image_id $row['image_id'];
$image_name $row['image_name'];
$cat_id $row['cat_id'];
$image_file $row['image_media_file'];
$image_keywords $row['image_keywords'];
$worknum $worknum 1;
$imgsize = @GetImageSize($root_path."/data/media/".$cat_id."/".$image_file);
$imgwidth $imgsize[0];
$imgheight $imgsize[1];
$image_width $imgwidth;
$image_height $imgheight;
  if (
$image_width == '' || $image_height == '') {
  echo "There was a problem checking the image file dimension.";
  if (
$image_keywords == '') {
  $image_keywords $image_width."x".$image_height; //You can edit these to include
} else {
  $image_keywords $image_keywords.",".$image_width."x".$image_height; //other keywords if you want
"<a href=\"/details.php?image_id=".$image_id."\" target=\"_blank\">Image ID: ".$image_id."</a><br>\n";
"Image Name: ".$image_name."<br>\n";
"Filename: ".$image_file."<br>\n";
"Real Size: ".$imgwidth."x".$imgheight."<br>\n";
"Set Size: ".$image_width."x".$image_height."<br>\n";
"Keywords Set To: ".$image_keywords."<br><hr>\n";
$sql "UPDATE ".IMAGES_TABLE." SET image_width = '$image_width', image_height='$image_height', image_keywords='$image_keywords' WHERE image_id = '$image_id'";
$result mysql_query($sql) OR die("HAHAHAHAHA! You Fail At Life!");

} else {
echo "All images sizes are currently set.";


Also you might want to open db_field_definitions.php and add:
Code: [Select]
$additional_image_fields['image_width'] = array('Width');
$additional_image_fields['image_height'] = array('Height');

Now you can edit width and height in the admin panel.

Now just go to your AdminCP and click set_sizes.php in the plugin section. It will get the width and height of the image file and set each one in the database.
It will also add WIDTHxHEIGHT(such as 1024x768) as a keyword. It checks to make sure it doesn't delete the keywords you already have, too. You will want to run this plugin whenever there are new images added to the gallery.

After that, just run the "Rebuild Search Index" plugin that comes with 4images. Now try it! Go to your gallery search page and type in a size as a keyword. You can type just one like "768" or the whole thing "1024x768". The new width and height values are also very useful in other mods and for building various templates.

That's it for this one, enjoy. Also, watch for a few other simple admin tools that I'll be posting. Maybe I'll just add them to this thread, instead of making a thread for each one.

I wasn't sure if 4images had an easy way to do this already, and I needed it, so I set this up on my site.


Code: [Select]
Code: [Select]
function browser_info($agent=null) {
  // Declare known browsers to look for
  $known = array('msie', 'firefox', 'chrome', 'safari', 'webkit', 'opera', 'netscape',
    'konqueror', 'gecko');

  // Clean up agent and build regex that matches phrases for known browsers
  // (e.g. "Firefox/2.0" or "MSIE 6.0" (This only matches the major and minor
  // version numbers.  E.g. "" is parsed as simply "2.0"
  $agent = strtolower($agent ? $agent : $_SERVER['HTTP_USER_AGENT']);
  $pattern = '#(?<browser>' . join('|', $known) .
    ')[/ ]+(?<version>[0-9]+(?:\.[0-9]+)?)#';

  // Find all phrases (or return empty array if none found)
  if (!preg_match_all($pattern, $agent, $matches)) return array();

  // Since some UAs have more than one phrase (e.g Firefox has a Gecko phrase,
  // Opera 7,8 have a MSIE phrase), use the last one found (the right-most one
  // in the UA).  That's usually the most correct.
  $i = count($matches['browser'])-1;
  return array($matches['browser'][$i] => $matches['version'][$i]);



Code: [Select]
Code: [Select]
$ua = browser_info();

if ($ua['firefox']) {
$doctype = "";
} else {
$doctype = "<!DOCTYPE HTML>";

if ($ua['msie']) {
$msie = 1;
} else {
$msie = 0;

"doctype" => $doctype,
"msie" => $msie


Now use the example to create your own. The examples allow you to display a different DOCTYPE for Firefox using {doctype},
or you can show some html to Internet Explorer users only, by using {if msie} html... {endif msie}

Other check types:

Replace firefox with a browser that we setup in the $known = array
Code: [Select]
if ($ua['firefox']) ... // true
if ($ua['firefox'] > 3) ... // true
if ($ua['firefox'] > 4) ... // false
if ($ua['browser'] == 'firefox') ... // true
if ($ua['version'] > 3.5) ... // true

Very simple, I know. But very useful. It saved my site from being broken in some browsers by letting me change the doctype, and displaying a message to IE users to get a better browser.

Is there a mod out there to do this? I'd like for a user to be able to hit a "Reply" button on any comment, to respond to it. The new comment would then appear under the first one as a response.

So it would be kind of like this:

-Good photo.

-Love this image
----Thanks, it's mine.
--------Well, good job then.

-*troll* *troll* *troll*

-I hate this image, it's ugly!

So awhile back, I built a screensaver mod to replace the one that used to be available, but was taken down when he left the site. Basically it loads a custom page as a windows screensaver, and that page displays the users lightbox images as a fullscreen slideshow with controls. So now I'm looking for a way for the user to change the order of the images in his lightbox. That way you would also be changing the order that the images appear in the screensaver. Drag and drop would be awesome, but even if it's just setting a number for each image, that would work. Does such a mod exist somewhere?

Chit Chat / Advice on my template...
« on: April 06, 2011, 04:26:54 PM »
Not sure if this is the right place for this thread or not. I don't really need help with my template, just suggestions/advice.

I'm rebuilding my template again and was looking to see what people think about what I'm doing with it, before I completely redo everything. My site:

Everything that is green is from my original design, which means mostly everything is still the original. So far I've only redesigned thumbnail_bit and category_bit. I've modded the thumbnailer so that is crops all the thumbnails to the exact same size. If you look at the New Wallpapers section on the homepage, you'll see that each thumbnail is a perfect square. If it is new, it adds a flashing "New" logo in the corner. Every thumbnail has a curved arrow in the bottom corner to tell people to put their mouse there to "flip" it over. So when you mouseover, the thumbnail fades out, and you see the information about it. Now if you scroll down, have a look at the categories. It looks similar, but instead, it's a random thumb, and the category name is displayed on top of the thumb. So, do these look good? Do they seem easy to use and whatnot?

I was going to make the details part of the thumbnail_bit look nicer, with a nice table made with some graphics, and put more information about the image. But then I thought about instead, putting the details on top of the thumbnail, like I did with the categories, and get rid of the part that you get when you mouseover. Which way do you guys think would look better? And if I keep the mouseover part, does the arrow look okay, or does it look bad with so many arrows all over the place?

And as for the rest of the template, a few people told me that the green was ugly, and I should change it. I was just wondering what other people thought about the green colors. And what about the rest of the design in general? Any parts that you think look good or bad? And tips on things you think I should change? Like I said, just want to see what people think of it before I rebuild everything. Thanks to anyone to takes the time to have a look a tell me what they think.


Oh, and I already know that the colors in the news section at the bottom are all messed up. I haven't fixed them yet because I might not keep the news section.

I was using the screensaver mod by KurtW, but since I've had to restore an older backup of my sites, it's not working. Since the mod is no longer available for download, I can't fix it.

So now I'm looking for a different screensaver mod, that can automatically make a screensaver from images in my gallery, with a user being able to select which images they want. I've searched around, but I don't think anyone else has made such a mod. Has anyone found another screensaver mod like that? Or is anyone working on one? If not, maybe someone knows of something else that I might be able to modify and make work for 4images.

I've been through a good 100 or so threads of people asking for help with the auto-thumbnailer, but I still can find an answer to this.

When I go to make thumbnails for new images, I choose to check for maybe 1000 images at a time. It'll list all 1000 images that need thumbnails, but when I click the "Create Thumbnails" button, it will stop after 100 or so. I remember a while back, maybe 2 years ago, I had the same problem, but I found a thread where someone posted a fix for the thumbnailer.php file, and I was able to make all 1000 thumbs a one time, and I even remember doing 2000 in one page sometimes. I have an extremely large number of images that I add with the batch uploader plugin, over 200,000, and it just isn't good enough to only do 100 thumbnails at a time. I've already tried things such as increasing the execution time and memory limit in php.ini, and that didn't help. I'm pretty sure that the fix was in thumbnailer.php itself.

Does anyone remember what that fix was, or does anyone know of another fix for this? Any help would be greatly appreciated. I'm currently using 1.7.6

I've searched the forums for this but found nothing. I could swear I've seen this before.

Does anyone know how to alter the random category image code so that instead of using a random image, it uses the first image from that category? I've seen V@no's Category Image Mod, but it looks a little outdated now, and I don't want to have to select the image for each category manually. I have a gallery full of comics, and since the first image is always the cover, it would show the cover next to each category that way.

Thanks in advance.

Using latest version 1.7.6

Pages: [1]