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 - dp

Pages: [1]

in standard installation of 4images users must login to be able to see the detail image by clicking a thumb. Does anybody know how I can configure 4images to prompt the details link for thumbnails at unregistered users, too? I would really like to present my detail images to every user, either logged in or not.

Thanks very much for your suggestions!

Sorry, this was caused by a database error. After deleting all entries in the images table and rebuild it via ACP, all thumbs are prompted with link to detail image now.

Mods & Plugins (Releases & Support) / [MOD] similar images
« on: January 19, 2010, 03:59:32 PM »
This Mod displays thumbs of images similar to the choosen one on the details page. Similarity is recognized by text-comparison of image keywords (or image description, if one likes better). From the whole set of similar picture a randomized subset is selected to be displayed. You can configure this number of displayed thumbs.

This Mod uses metadata of the images to find similar pics. It just takes e.g. the keywords of the image displayed on the details page and performes a text-comparison via php function "similar_text()". That means, if your metadata does not properly describe your images in a consist and structural way, the result will not be satisfyingly.

You must fit some variables of this mod to your gallerys image data. The best way to to this is still to vary variables value and look at the results.
For example:
similar_text() calculates similarity of two strings by setting a defined variable at 0 to 100, where 0 means no and 100 complete similarity.
Therefor in this Mod "$percent_limit = 80; " is the value that devides similar images from non-similar. Descending the value results more similar images and vice versa.

In this Mod I use only a part of 50 letters of the compared metadata. This is because in my database the first keywords contains the most relevant information. So if one image has 20 keywords and a real similar image only 5, text-comparison will result a low similarity. If I use only the first keywords for comparison, comparison will fit much better.
Vary the number of letters in the substr()-function or remove this function to use the whole metadata.

This Mod is based on Mod Random pictures by V@tno

Files affected
[change] details.php
[change] lang/english/main.php
[change] lang/yourlanguage/main.php
[change] templates/default/details.html

open details.php, locate
//--- Show Image --------------------------------------

insert before
//------- MOD Similar Images
$image_keywords  substr($image_row['image_keywords'], 050); //keywords of actual image
$image_description  $image_row['image_description'];          //description of actual image
$image_id_self  $image_row['image_id'];                       //id of actual image
$i_ids 0;
$i_ids_max 4;                                                 //max number of thumbs displayed
$image_ids "";
$percent_limit 80;                                            //limit of similarity; vary to fit to your database!
$percent_minimum 40;                                          //minimum of similarity; vary to fit to your database!

//-- select all images and identify similar images
//-- write a string $image_ids with the set of id's, comma seperated
//-- if there are no similar images, descend $percent_limit and try once more
$sql "SELECT image_id, image_name, image_description, image_keywords, image_active
        FROM "
        WHERE image_active = 1"
$result_allimages $site_db->query($sql);

while ((
$i_ids == 0) && ($percent_limit $percent_minimum)) {
        while (
$image_row_allimages $site_db->fetch_array($result_allimages)){
similar_text $image_keywordssubstr($image_row_allimages['image_keywords'], 050), $percent );
//              similar_text ( $image_description, substr($image_row_allimages['image_description'], 0, 50), $percent );
if (($percent $percent_limit) && ($image_row_allimages['image_id'] != $image_id_self)) {
$i_ids $i_ids 1;
$image_ids .= $image_row_allimages['image_id'] . ", ";
$percent_limit $percent_limit 5;

//-- remove the last comma in $image_ids
if (strlen($image_ids) > 0) {
$image_ids substr($image_ids0strlen($image_ids)-2);
//-- set $i_ids to its maximum, for correct mysql statement below
if ($i_ids 4$i_ids $i_ids_max;

//-- build table with thumbs of similar images (only if there are some, of course)
if ($i_ids == 0) {
$similar_images "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\"><tr class=\"imagerow1\"><td>";
$similar_images .= "</td></tr></table>";
else  {

//---- select similar images, there id's are in the set $image_ids now
//---- randomized and limited
$sql "SELECT *
        FROM "
        WHERE image_id IN (" 
$image_ids ")
        ORDER BY RAND()
        LIMIT "
$result_similarimages $site_db->query($sql);
$num_rows_similarimages $site_db->get_numrows($result_similarimages);

//---- build table and table-cells
if (!$num_rows_similarimages)  {
$similar_images "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\"><tr class=\"imagerow1\"><td>";
$similar_images .= "</td></tr></table>";
else  {
$similar_images "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\">";
$count 0;
$bgcounter 0;
  while (
$image_row_similarimages $site_db->fetch_array($result_similarimages)){
    if (
$count == 0) {
$row_bg_number = ($bgcounter++ % == 0) ? 2;
$similar_images .= "<tr class=\"imagerow".$row_bg_number."\">\n";
$similar_images .= "<td width=\"".$imgtable_width."\" valign=\"top\">\n";

$similar_images .= $site_template->parse_template("thumbnail_bit");
$similar_images .= "\n</td>\n";
    if (
$count == $config['image_cells']) {
$similar_images .= "</tr>\n";
$count 0;

  if (
$count 0)  {
$leftover = ($config['image_cells'] - $count);
    if (
$leftover >= 1) {
      for (
$f 0$f $leftover$f++) {
$similar_images .= "<td width=\"".$imgtable_width."\">\n&nbsp;\n</td>\n";
$similar_images .= "</tr>\n";
$similar_images .= "</table>\n";

//-- register template-keys
"similar_images"        => $similar_images,
"lang_similar_images"   => $lang['lang_similar_images']
//------- End similar images---------

open lang/english/main.php
insert at the bottom (before ?>)
//--- MOD similar pictures dp
$lang['lang_similar_images'] = "similar images";

open lang/yourlanguage/main.php
insert at the bottom (before ?>)
//--- MOD similar pictures dp
$lang['lang_similar_images'] = "translation of "similar images"";

open templates/default/details.html
place {lang_similar_images} and {similar_images} were ever you want to display the table of thumbs with similar images

Discussion & Troubleshooting / How to register a new global variable?
« on: October 08, 2009, 03:28:05 PM »
I'm working with Chris Mod for an alternative download directory xxx: xxx: 4homepages.   de/forum/index.   php?topic=7499.   msg33712#msg33712 and would like to use a new global variable to determine the name of the download folder, accessable from every part of the 4images script.   

So I tried just

global $dp_download_folder;

in includes/global.   php, index.   php and many others, but the variable was not accessible from any function or script in download.   php or functions.   php.   

As you see, I'm not very familiar to php and try my very best to learn.    For all you php-professionals arround here, this is a quiet simple question for sure.    So I hope you will have the answer.   

Many Thanks in advance!

Pages: [1]