This could be useful if we want to load smaller images in the Timeline.

Comments

pol’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

christiaan_’s picture

Version: » 7.x-1.x-dev
Category: task » feature
StatusFileSize
new1.15 KB

Great module - thank you. From Pol's example I got it working with the following changes in the views_timelinejs_plugin_style_timelinejs.inc file. It will now use the image style of the selected image field.

--- /views_timelinejs/views_timelinejs_plugin_style_timelinejs.inc
+++ /views_timelinejs/views_timelinejs_plugin_style_timelinejs.inc
@@ -485,6 +485,13 @@
             $value = $view->field[$tmp['fieldname']]->get_value($row);
             if (is_array($value)) {
               $value = array_shift($value);
+              // Allow for imagefield image style selection
+              if ($view->field[$tmp['fieldname']]->options['settings']['image_style']) {
+                $image_style = image_style_load($view->field[$tmp['fieldname']]->options['settings']['image_style']);
+                $preview_file = image_style_url($image_style['name'], $value['uri']);              
+                image_style_create_derivative($image_style, $value['uri'], $preview_file);
+                $value['uri'] = $preview_file;
+              }            
             }
             if ($conversion_callback = views_timelinejs_get_callback($tmp['handler'], $tmp['field_type'], 'media_sources')) {
               $media['formatted'] = call_user_func($conversion_callback, $value, array('field' => $tmp));
jamescook’s picture

If you're seeking to apply patch #3 to current dev, you need to do some prefixing with $this->.

sdsheridan’s picture

Issue summary: View changes

Definitely need this included!

Shawn

liquidcms’s picture

Status: Closed (fixed) » Active

pretty sure this has not been committed so changing back to Active.

liquidcms’s picture

#3 does not work; likely as jamescook suggested.

on a similar note; i dont think any field styles are used by this module.. which would be good.. but i'll open a separate issue (e.g. date formatting is allowed in the date field by the view; but ignored when displayed).

liquidcms’s picture

this is better:

// Allow for imagefield image style selection
              if ($this->view->field[$tmp['fieldname']]->options['settings']['image_style']) {
                $image_style = image_style_load($this->view->field[$tmp['fieldname']]->options['settings']['image_style']);
                $preview_file = image_style_url($image_style['name'], $value['uri']);
                image_style_create_derivative($image_style, $value['uri'], $preview_file);
                $value['uri'] = $preview_file;
              }

but, even though the uri to the img is now correct; the inline style is set to still make the img small... my guess is the timeline js is setting size.

zincdesign’s picture

I'd love this feature. How do I implement this @Liquidcms ?

I have tried pasting in the above but in various places in the views_timelinejs_plugin_style_timelinejs and it's throwing up errors so i am sure I am not doing it correctly

liquidcms’s picture

look at the post in #3... you should be able to tell from there where the code goes. search for the lines:if

(is_array($value)) {
               $value = array_shift($value);

and then paste the code i provided just after that.

zincdesign’s picture

Thanks for your help Liquidcms. It throws up the same error which make me think I was adding the code correctly.

Notice: Undefined index: image_style in views_timelinejs_plugin_style_timelinejs->render() (line 586 of ........./sites/all/modules/views_timelinejs/views_timelinejs_plugin_style_timelinejs.inc).

If you can assist any further I'd appreciate it but I totally understand if not. Thanks again :-)

liquidcms’s picture

that's not an error; its a Notice. just disable php from showing notices... they don't hurt.

is your timeline using the style? it actually kind of sounds like you just haven't set a style for your image field in the view.

letrotteur’s picture

Please provie a patch file. This is a must have feature or you end up loading huge image for nothing.

roderik’s picture

Issue summary: View changes
Related issues: +#2117733: Add separately selectable thumbnail field

Thanks for this. There should be no need to call image_style_create_derivative() though. It just slows down loading the page. This should be enough:

            // Allow for imagefield image style selection.
            if ($this->view->field[$tmp['fieldname']]->options['settings']['image_style']) {
              $value['uri'] = image_style_url($this->view->field[$tmp['fieldname']]->options['settings']['image_style'], $value['uri']);
            }

I will integrate this into the patch #2117733-9: Add separately selectable thumbnail field because they're changing the same lines, and you want to have a mapping for thumbnail too.

WorldFallz’s picture

Status: Active » Fixed
pol’s picture

Revival ! :)

WorldFallz’s picture

you bet! This is an AWESOME module... kudos to all those maintainers who came before me.

replicaobscura’s picture

This seems to introduce the problem of, in the case of an image field with no image in it, the image style URL is still returned with no image filename on the end, causing it to try to generate a thumbnail of the 404 page indicating that there is no image.

Shouldn't it check to see if the field is empty before trying to apply an image style to it?

replicaobscura’s picture

WorldFallz’s picture

Status: Fixed » Active

Yeah... I noticed this myself. Working on a fix.

replicaobscura’s picture

I did post a patch here that resolves it if you'd like to use that--it's a really simple code fix.

WorldFallz’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.