"Random pictures" function in Coppermine functions.inc
Post new topic   Reply to topic   Printer Friendly Page     Forum IndexCoppermine
Author Message
MotoWriter
Newbie


Joined: Jul 19, 2007
Posts: 30

PostPost subject: "Random pictures" function in Coppermine functions.inc
Posted: Wed Aug 01, 2007 5:16 am
Reply with quote

I'm using the Coppermine Random Gallery Pix block and would like to filter the files selected so the thumbnails of the pix returned do not exceed a certain width. I have panoramic pix in my albums and if a couple of panos get pulled for display in the Random block, my page width increases and the browser puts up a scroll bar for the page with an extra wide table produced by Coppermine.

K, so I went over to the Coppermine forum and they are sending people with questions about Coppermine 1.3.1 in Dragonfly back here. But I did find a good lead in this post: coppermine-gallery.net...#msg45369. I looked at the functions.inc file in /includes/coppermine and located this code:

Code:
$result = $db->sql_query("SELECT $select_columns FROM {$CONFIG['TABLE_PICTURES']} AS p INNER JOIN {$CONFIG['TABLE_ALBUMS']} ON (".VIS_GROUPS." AND $thisalbum) WHERE  randpos IN ($random_num_set) AND approved = 1 GROUP BY p.pid, p.filepath, p.filename, p.title, p.keywords, p.url_prefix, p.filesize, p.pwidth, p.pheight, p.ctime, p.aid ORDER BY RAND() $limit");
} else {
$result = $db->sql_query("SELECT $select_columns FROM {$CONFIG['TABLE_PICTURES']} AS p INNER JOIN {$CONFIG['TABLE_ALBUMS']} AS a ON (p.aid = a.aid AND ".VIS_GROUPS." AND $thisalbum) WHERE approved=1 GROUP BY p.pid, p.filepath, p.filename, p.title, p.keywords, p.url_prefix, p.filesize, p.pwidth, p.pheight, p.ctime, p.aid ORDER BY RAND() $limit");

Not being very experienced with php or SQL I don't know how to alter the WHERE statement to filter based on an image pwidth property.

Can someone please help with altering those queries to filter out any results over a given width? Thanks!!


MotoWriter's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Linux/1.3.37/4.1.21/4.4.7/9.1.2.1
Back to top
View user's profile Visit poster's website
MotoWriter
Newbie


Joined: Jul 19, 2007
Posts: 30

PostPost subject: Re: "Random picturs" function in Coppermine functions.inc
Posted: Wed Aug 01, 2007 8:35 pm
Reply with quote

Resolved... surprisingly simple fix.

The random gallery pix is in the main Gallery page (as I have it configured) and is a block I've placed on most of my main pages. The thumbnails of the randomly selected pix are sized the same as the original pic. For panos, with dimensions like 1000x250, it produces a thumbnail of uniform height, but proportional width. The thumbnails are always 100px high, so panos like the one with a 4 to 1 dimension were sizing to 400 x 100. With four thumbnails in the table, you could have a table that was, for example, 1600px wide... which was causing the browser to add a horizontal scroll bar and pushing the my right blocks off the screen.

The fix was to set a conditional up for the WHERE clause that selects random records. I thought it best to just address the proportions and not pull and pix that were more than 2x wider than tall.

This conditional, inserted right after WHERE, worked to set that contraint, with an AND in there to keep the other clauses of the WHERE statement:
Code:
(p.pheight/p.pwidth)>.5 AND 

I changed two files for this: the block-CPG-center-Random_pictures.php block (which I'm using to show random pix on my index and most other pages) as well as the /includes/coppermine/functions.inc file, which governs the random pix "block" that is included in the default main gallery page with the out of box install of Dragonfly/Coppermine.

Hope that helps others who want to address this issue...


MotoWriter's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Linux/1.3.37/4.1.21/4.4.7/9.1.2.1
Back to top
View user's profile Visit poster's website
MotoWriter
Newbie


Joined: Jul 19, 2007
Posts: 30

PostPost subject: Re: "Random picturs" function in Coppermine functions.inc
Posted: Wed Aug 01, 2007 8:55 pm
Reply with quote

Note to mods... u may want to correct my misspelling in the Subject of the above posts so "random pictures" comes up in a search by Subject.

MotoWriter's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Linux/1.3.37/4.1.21/4.4.7/9.1.2.1
Back to top
View user's profile Visit poster's website
rlgura
1000+ Posts Club


Joined: Mar 27, 2006
Posts: 1148
Location: Cleveland, OH USA

PostPost subject: Re: "Random pictures" function in Coppermine functions.inc
Posted: Thu Aug 02, 2007 4:45 pm
Reply with quote

Cool - I've got one in mine that does that and it seems to come up more often than any other picture! Now I can stop being lazy and actually fix that! Smile
_________________
Admin - Great Lakes Web Designs
Theme Designer - WebSite Guru Designs
Site Admin - Families with Food Allergies

rlgura's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Linux 2.6.27-grsec/Apache 2.2.11/MySQL 5.0.67-community-log/PHP 5.2.8/DF 9.2.1
Back to top
View user's profile Visit poster's website
rosbif
500+ Posts Club


Joined: Jan 13, 2005
Posts: 571
Location: Paris, France

PostPost subject: Re: "Random pictures" function in Coppermine functions.inc
Posted: Wed Mar 24, 2010 5:14 pm
Reply with quote

Just found this via a search as it's been bugging me - should be added to the next DF release!

Thanks Motowriter


rosbif's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Linux/2.2.11/5.0.77/5.2.8/9.2.1
Back to top
View user's profile Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   Printer Friendly Page     Forum IndexCoppermine All times are GMT
Page 1 of 1


Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Dedicated Server & Bandwidth Sponsored by DedicatedNOW
User Info [x]

Welcome Anonymous

Nickname
Password
(Register)

Last CVS commits [x]

Languages [x]

Community [x]

Support for DragonflyCMS in a other languages:

Deutsch
Español

X-links [x]
UltraEdit Browse Happy logo Firefox MySQL PostgreSQL Valid CSS! Valid XHTML 1.0! Unicode Encoded Badge NukeBiz Resources Raven DragonflyCMS Dedicated Now InsideSupport Lampe Berger

Preview theme [x]
Each user can view the site with a different theme.
Themes marked with a * also change the forum look.


You are seeing squares or questionmarks on this page?

All content of this website is copyrighted by the Creative Commons NC-SA
The logos and trademarks used on this site are the property of their respective owners
We are not responsible for comments posted by our users, as they are the property of the poster.
Our server runs on a P3 1.2GHz with 512MB RAM with no accelerators
Support GoPHP5.org
This page generated in 0.3753 seconds with 17 DB Queries in 0.0389 seconds
Memory Usage: 3.07 MB
Interactive software released under GNU GPL, Code Credits, Privacy Policy