Closed (fixed)
Project:
Flickr
Version:
7.x-1.x-dev
Component:
flickr (main module)
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
8 Apr 2015 at 20:39 UTC
Updated:
19 May 2015 at 14:44 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
lolandese commentedComment #2
vbouchetHi lolandese,
I started to work on that request. How do you think we should deal with the 'time ago' option as there is no date format for it? I planned to add a "fake" date format in the list but then if the user select something else than 'time ago' for the caption, it doesn't make sense to display a date when hovering it. Should we simply take the decision to hide the "Caption hovered" option when something else than 'time ago' is selected for the Caption option (we can use states API for that)?
Can you also let me know how to display the date in the album title? (for now I haven't been able to have any date while displaying an album).
Let me know your opinion and I will finalize the patch for this feature.
Thanks,
Comment #3
lolandese commentedYes. Options through function system_get_date_types seems the right approach. 'Time ago' (line 619 in flickr.module) seems indeed necessary to add as 'fake' option.
Adding the option 'None' would take care of that. It might be that it is still desired to show a long date when hovering the short format in the caption. Anyway, maybe leave this up to the sitebuilder. 'Time ago' is IMHO anyway the best option for the caption to offer as being the default.
Enable Flickr Filter, add it to a text format and use in the node body e.g.:
[flickr-user:id=public, size=q, num=8,location=48.867556/2.364088, date=2015-01-11, filter=interesting, sort=views]See the last album on this demo page.
Both location and date are new features only present in the dev version for now. In Flickr Blocks they can even be taken dynamically from a Location/Geofield or Date field of the node on the same page as the block. Same way it was already done for node taxonomy terms and Flickr tags.
Thanks in advance for your help.
Comment #4
vbouchetHi,
Please find a patch to provide the configurable date format feature. Let me know if it's ok.
Comment #5
lolandese commentedReview:
Only the date included in the album title can lead to titles like:
Most viewed, most interesting Flickr photos near République, Paris, France taken 3 months to 3 months ago
or
Most viewed, most interesting Flickr photos near République, Paris, France taken on Sunday, 11 January, 2015 - 00:00
Cause of the first is the granularity of the 'Time ago' format. It can be resolved by removing this option for the 'Album title' or using a granularity that at least includes the day.
The second could be solved by using substr($str, 0, strrpos($str, '-').
It looks for the position the first occurunce of the dash that separates the date and time. Then it only takes the part in front of it.
In practice in the current code in flickr.inc line 744 replace
with
Similar for line 748 (multiple days).
Some other points:
Maybe put the field group 'Date formats' right under 'Global options'?
The field descriptions 'Select the appropriate date format to be displayed..' seems a bit redundant as the field group is already named 'Date formats'.
Proposed field titles and descriptions:
T: When hovering an image (mouse-over)
D: -
T: In the image caption
D: -
T: When hovering a date in the caption
D: If you don't want to display anything when hovering the date, select 'None'.
T: In the album title
D: -
Overall this is a nice addition and exactly what was intended.
Thanks.
Comment #6
vbouchetHi,
Regarding the "time ago" option for the album title, maybe we should simply check the two dates are different (after the transformation). So in that example we will have "Most viewed, most interesting Flickr photos near République, Paris, France taken 3 months ago". For another album we may have "Most viewed, most interesting Flickr photos near République, Paris, France taken 5 months to 3 months ago" which make sense from my point of view. It may be interesting to add a "hover option" to display the full date (as for the image caption).
Regarding the hour displayed, I think it's the expected behavior. If you don't want to display the hour, use a different date format which doesn't contain the hours. It makes more sense as it respects the selected format.
Let me know your opinion on these two points and I will also adapt labels and descriptions.
Comment #7
lolandese commentedI agree. Probably the most elegant solution.
I agree. If that can be implemented right away, nice. If it will turn in an additional feature request to take care of later, fine as well.
Both the date used in Flickr Filter and Date field attached to a node (used by Flickr Block) have a granularity of 'Day'. No time is given by the user, thus expected is only a 'Day'. The time is added programmatically to have correct results returned. E.g.:
The user given date=2015-01-11 turns programmatically into two parameters for the Flickr request, min_taken_date=2015-01-11 00:00:00 and max_taken_date=2015-01-11 23:59:59. We don't want to bother the users with times to fill in.
We prefer to not bother our sitebuilders to create a custom date format. Most are using the Flickr module because less 'tech savvy' or as a time saver. For both we would like to avoid more hassle. Several solutions possible:
P.S.:
The previously suggested substr method to cut off the time part of a date does only work if date and time are separated by a dash and if the date doesn't contain any dashes. So on a format like '2015-04-30 12:50' it results in an album title like:
Most viewed, most interesting Flickr photos near République, Paris, France taken on 2015-01
Instead of the dash (-) it is safer to use the colon (:) that should only be present in a time. In code that would look like:
substr($str, 0, strrpos($str, ':') - 3)-3 to exclude also the hour part of the time. I know, it's not too elegant but it works for most cases.
We could also simply remove the last word of the string:
This should work for all the default provided date format (short, medium, long) but obviously should be skipped on 'time ago' or custom date formats that omit the space between date and time or put a space in the time (e.g. '04:12:00 pm').
Even better:
In a regular expression we could "look" for the first occurrence of a number followed by a colon and use anything that preceeds it. Something like:
See http://rubular.com/r/7IJhj19P9K.
Comment #8
vbouchetPlease find an updated patch and an interdiff file.
I will be off for the next two weeks so if there is any issue with the patch, feel free to jump and update it.
Please create a separate feature request for the "hover option" on the album title dates.
Thanks,
Comment #9
vbouchetComment #10
lolandese commentedReview:
Most viewed, most interesting Flickr photos near République, Paris, France taken on Sunday, 11 January, 2015 - 00:00
if the date format contains a time. I would prefer to truncate it to a date only so we can use the core date formats without the need to create Flickr module specific ones (see also below). Also because the time will always be 00:00 as the current granularity is 'day'.
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'l, d F, Y-custom' for key 'formats': INSERT INTO {date_formats} (format, type, locked) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2); Array ( [:db_insert_placeholder_0] => l, d F, Y [:db_insert_placeholder_1] => custom [:db_insert_placeholder_2] => 0 ) in drupal_write_record() (line 7207 of /home/martin/www/green/includes/common.inc).While it could be taken care of with more code to catch this exceptional case, I would prefer to do without custom date formats, as also indicated above. I had second thoughts about my own proposal in #7. Sorry about that.
Comment #11
lolandese commentedAttached patch implements all points mentioned in #10 plus it adds the - None - option to all Flickr date formats to give sitebuilders the possibility to omit the display of a date in any element (caption, image hover, caption date hover, album title).
Comment #12
lolandese commentedThe regular expression
/^(.*?)[-|\s].\d*:/instead of/^(.*?)[-|\s].\d+:/(* instead of +) matches also one digit hours (e.g. 12 June 1965 2:00:00).Comment #13
lolandese commentedAttached patch does as above, plus:
Tested with Flickr Filter. To test also with Flickr Block and from scratch on a clean install.
Comment #14
lolandese commentedAttached patch additionally:
Comment #15
lolandese commentedAdditionally attached patch corrects an unrelated bug that was introduced in https://www.drupal.org/commitlog/commit/2102/8d757ac25a0724bcd2773be03d5....
Also Flickr Block and install/uninstall seem to work fine now with the new configurable date format feature.
Opened a child issue for #2483241: More date format options.
Thanks for your contribution.