First off -this is a great module and by far the best photo album module for Drupal. Many thanks to eastcn for developing and maintaining this.
It's also great that there are now new ways to sort the photo display order (timestamp, weight, filesize, comments, votes) in both (ascending, descending) order.
However, I wanted to have the pictures be sorted chronologically i.e. first picture taken appears first. This requires EXIF information, and was way beyond my skill level to attempt. I settled for the next best thing : sort by filename. In most cases sorting photos by filename in ascending order will result in chronological order. I was able to accomplish this by applying the following patch to photos.module.
--- photos.module 2009-12-29 20:35:18.000000000 -0700
+++ photos.module.new 2010-04-10 18:25:01.000000000 -0600
@@ -459,7 +459,7 @@
case 1:
return $node->album['cover']['view'];
case 2:
- $order = explode('|', ($node->album['imageorder'] ? $node->album['imageorder'] : variable_get('photos_display_imageorder', 'timestamp|desc')));
+ $order = explode('|', ($node->album['imageorder'] ? $node->album['imageorder'] : variable_get('photos_display_imageorder', 'filename|asc')));
$order = _photos_order_value_change($order[0], $order[1]);
$limit = $node->album[$type.'_viewnum'] ? $node->album[$type.'_viewnum'] :variable_get('photos_display_'.$type.'_viewnum', 10);
$result = db_query_range('SELECT f.filepath, f.filemime, f.timestamp, f.filename, f.filesize, u.uid, u.name, p.* FROM {files} f INNER JOIN {x_image} p ON f.fid = p.fid INNER JOIN {users} u ON f.uid = u.uid WHERE p.pid = %d'. $order, $node->nid, 0, $limit);
@@ -1484,7 +1484,7 @@
}
function _photos_order_value_change($field, $sort){
- $array = array('weight' => 'p.wid', 'timestamp' => 'f.fid', 'comments' => 'p.comcount', 'visits' => 'p.count', 'filesize' => 'f.filesize');
+ $array = array('filename' => 'f.filename', 'weight' => 'p.wid', 'timestamp' => 'f.fid', 'comments' => 'p.comcount', 'visits' => 'p.count', 'filesize' => 'f.filesize');
$array1 = array('desc' => 'desc', 'asc' => 'asc');
if($array[$field] && $array1[$sort]){
return " ORDER BY $array[$field] $array1[$sort]". ($array[$field] != 'f.fid' ? ', f.fid DESC' : NULL);
@@ -1501,6 +1501,7 @@
function _photos_order_link($arg, $count = 0, $link = 0, $limit = 0){
$field = array(
+ 'filename' => t('By filename'),
'weight' => t('By weight'),
'timestamp' => t('By time'),
'comments' => t('By comments '),
@@ -1539,6 +1540,8 @@
function _photos_order_label(){
return array(
+ 'filename|desc' => t('Filename - descending'),
+ 'filename|asc' => t('Filename - ascending'),
'timestamp|desc' => t('Date - newest first'),
'timestamp|asc' => t('Date - oldest first'),
'weight|desc' => t('Weight - smallest first'),
@@ -1670,4 +1673,4 @@
Then modify all instances of this string "timestamp|desc" to "filename|asc" in inc/photos.admin.inc, inc/photos.album.inc, inc/photos.data.inc, inc/photos.form.inc. This makes the filename sort become default.
I then modified photos.css to hide the sort ability from the average user, using display:none; I'm sure this can be done using the tpl files as well.
--- photos.css 2009-03-10 20:37:43.000000000 -0600
+++ photos.css.new 2010-04-10 18:29:04.000000000 -0600
+.photos_list_view_info, .photos_album_links {
+ display: none;
}
.photos_view_des, .photos_view_filename, .photos_list_view_des, .photos_list_view_filename{
+ display: none;
margin:4px 0;
padding:5px 8px;
}
I hope this is useful to someone...
Comments
Comment #1
eastcn commentedDo you mean pictures taken time?
This requires access to information from the exif, they are not necessarily accurate.
I will try out a patch. thanks
Comment #2
chakrax commented@eastcn - yes - the picture taken time from the exif is the best way to sort chronologically, in my opinion.
File creation time will produce unexpected results, depending on upload order.
Thanks again for a good module.
Comment #3
nathaniel commentedClosing old issues and leaning toward custom drag/drop weight sorting as the default. Please re-open or start a new issue if you would still like this feature in the latest release.
#652430: Drag and Drop Photos Re-arrange Grid
Comment #4
nathaniel commented