"Random pictures" function in Coppermine functions.inc
| Author |
Message |
MotoWriter


Joined: Jul 19, 2007 Posts: 30
|
Post subject: "Random pictures" function in Coppermine functions.inc Posted: Wed Aug 01, 2007 5:16 am |
|
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 |
|
 |
MotoWriter


Joined: Jul 19, 2007 Posts: 30
|
Post subject: Re: "Random picturs" function in Coppermine functions.inc Posted: Wed Aug 01, 2007 8:35 pm |
|
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 |
|
 |
MotoWriter


Joined: Jul 19, 2007 Posts: 30
|
Post subject: Re: "Random picturs" function in Coppermine functions.inc Posted: Wed Aug 01, 2007 8:55 pm |
|
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 |
|
 |
rlgura


Joined: Mar 27, 2006 Posts: 1148 Location: Cleveland, OH USA
|
Post subject: Re: "Random pictures" function in Coppermine functions.inc Posted: Thu Aug 02, 2007 4:45 pm |
|
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!
_________________ 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 |
|
 |
rosbif


Joined: Jan 13, 2005 Posts: 571 Location: Paris, France
|
Post subject: Re: "Random pictures" function in Coppermine functions.inc Posted: Wed Mar 24, 2010 5:14 pm |
|
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 |
|
 |
|
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
|

|
User Info ![Show/hide content [x]](themes/dragonfly/images/minus.png)
 Welcome Anonymous
Last CVS commits ![Show/hide content [x]](themes/dragonfly/images/minus.png)
Languages ![Show/hide content [x]](themes/dragonfly/images/minus.png)
Community ![Show/hide content [x]](themes/dragonfly/images/minus.png)
 Support for DragonflyCMS in a other languages:
• Deutsch
• Español
X-links ![Show/hide content [x]](themes/dragonfly/images/minus.png)
Preview theme ![Show/hide content [x]](themes/dragonfly/images/minus.png)
Each user can view the site with a different theme.
Themes marked with a * also change the forum look.
|