Announcement

  •  » Engine
  •  » Multi size : theme integration

#1 2012-01-27 18:46:41

flop25
Piwigo Team
2006-07-06
7037

Multi size : theme integration

Hello
I'm trying to catch the train of dev on trunk which I've missed for some weeks, and I've seen the commit about define_derivative name='derivative_params'
I have a theme which will require different sizes for thumbnails in one page : currently it just use a trigger and change the tpl var TN-SRC. But it seems the multi size url is given in the tpl via $pwg->derivative_url, and not in the php. I'm wondering how to have different derivative_params for one loop of $thumbnails ?

Last edited by flop25 (2012-01-27 18:47:00)


To get a better help : Politeness like Hello-A link-Your past actions precisely described
Check my extensions : more than 30 available
who I am and what I do : http://fr.gravatar.com/flop25
My gallery : an illustration of how to integrate Piwigo in your website

Offline

 

#2 2012-01-27 19:09:19

rvelices
Piwigo Team
2005-12-29
1960

Re: Multi size : theme integration

Code:

{define_derivative name='bigOne' width=...}
{define_derivative name='smallOne' width=...}

{foreach from=$thumbnails item=thumbnail}
<img src="{$pwg->derivative_url($bigOne, $thumbnail.src_image)}">
<img src="{$pwg->derivative_url($smallOne, $thumbnail.src_image)}">
{/foreach}

Offline

 

#3 2012-01-27 19:18:43

flop25
Piwigo Team
2006-07-06
7037

Re: Multi size : theme integration

Well I already understood that
my point is to alternate size and I prefer a full php solution without tpl file... I've though of one solution. A prefilter replace the {$pwg->derivative_url(... tag by a custom one, and this custom tag will be a tpl parsed-by-php file : that could be solution but it's very complicated


To get a better help : Politeness like Hello-A link-Your past actions precisely described
Check my extensions : more than 30 available
who I am and what I do : http://fr.gravatar.com/flop25
My gallery : an illustration of how to integrate Piwigo in your website

Offline

 

#4 2012-01-28 00:26:09

flop25
Piwigo Team
2006-07-06
7037

Re: Multi size : theme integration

my message might need to be clearer :
if the theme need cyclical sizes like http://fthrwght.com/autofocus/plusdemo/ and don't need to create a new full thumbnails.tpl (just css trick and thumbnail url to change), it will need a trigger and a prefilter to add tpl : it needs a smarty counter or if/elseif tag smarty. So it can't be in 100% php because we can't just change the tpl var $thumbnails['TN-SRC'], it needs prefilters and code tpl manipulation (substr or regex)

So my final question is : is-it possible to change the way to think ? not using {$pwg->derivative_url} in tpl, but doing an assign $pwg->derivative_url to the old tag {$thumbnails.TN-SRC}, to avoid complex prefilter


To get a better help : Politeness like Hello-A link-Your past actions precisely described
Check my extensions : more than 30 available
who I am and what I do : http://fr.gravatar.com/flop25
My gallery : an illustration of how to integrate Piwigo in your website

Offline

 

#5 2012-01-30 10:13:20

rvelices
Piwigo Team
2005-12-29
1960

Re: Multi size : theme integration

flop25 wrote:

So my final question is : is-it possible to change the way to think ?

well this is what we did with the derivatives :)

flop25 wrote:

not using {$pwg->derivative_url} in tpl, but doing an assign $pwg->derivative_url to the old tag {$thumbnails.TN-SRC}, to avoid complex prefilter

Note that we use the derivative_params to set the css ... so you'll probably need to change your tpl anyway.

For your specific link, you'll definitely need to know what the size of the derivative will be. It's true that derivative_url returns only the url, but the size could very easily be available in your tpl... For example on the picture_content.tpl we have the sizes available.

Offline

 

#6 2012-01-30 14:56:31

flop25
Piwigo Team
2006-07-06
7037

Re: Multi size : theme integration

rvelices wrote:

flop25 wrote:

So my final question is : is-it possible to change the way to think ?

well this is what we did with the derivatives :)

^^ I thought of that just after posting

rvelices wrote:

Note that we use the derivative_params to set the css ... so you'll probably need to change your tpl anyway.

well not in fact because the local_head is very usefull to add tpl which don't need te be in a specific file : so i think the designer will put their {define_derivative} there, as the same way I've already put dynamic css in.
And I've thought about the problem of cyclical/random/etc sizes : the best way -for me, maybe you have a better idea- is to substr "{$pwg->derivative_url($derivative_params, $thumbnail.src_image)}" by "{$thumbnails.my_derivative_url}", and use the php function which render derivative urls to assign my_derivative_url : derivative_url() is a function from the template class and I don't know how to handle that "outside of a the box"..
is it $current_derivative = new DerivativeImage($derivativeParams_01, $tplvar['TN_SRC']); and then $current_derivative->get_url()?
creating multiple instances of DerivativeImage will not cause perf issue ?

Last edited by flop25 (2012-01-30 14:57:32)


To get a better help : Politeness like Hello-A link-Your past actions precisely described
Check my extensions : more than 30 available
who I am and what I do : http://fr.gravatar.com/flop25
My gallery : an illustration of how to integrate Piwigo in your website

Offline

 

#7 2012-01-30 15:59:35

rvelices
Piwigo Team
2005-12-29
1960

Re: Multi size : theme integration

flop25, I really don't get what the problem is with the current implementation.
note that there is an event for generating derivative_params and a plugin might be able to change it.

What exactly do you want to do ?

Offline

 

#8 2012-01-30 16:15:43

flop25
Piwigo Team
2006-07-06
7037

Re: Multi size : theme integration

ok no problem
sry for disturbing you

take http://fthrwght.com/autofocus/plusdemo/ => the sizes are known, just the height can be set by the user Let's say 3 sizes to alternate.
Before multi size :
-dynamic css via localhead.tpl due to the height
-in themeconf.inc.php a trigger on loc_end_index_thumbnails, with
  $i=1;
  foreach ($tpl_thumbnails_var as $tplvar)
  {
$tplvar['TN_SRC']=PHPWG_THEMES_PATH."stripped_black_bloc/library/phpthumb/phpThumb.php?src=../../../../".$tplvar['FILE_PATH']."&w=".$conf_thumbnail_width[$i];
....

no prefilter

With multi size, as it's currently implemented :
-dynamic css via localhead.tpl
-in themeconf.inc.php a prefilter on loc_end_index_thumbnails, with substr "{$pwg->derivative_url($derivative_params, $thumbnail.src_image)}" by "{$thumbnails.my_derivative_url}
-in themeconf.inc.php a trigger on loc_end_index_thumbnails, with
  $i=1;
  foreach ($tpl_thumbnails_var as $tplvar)
  {
          $current_derivative = new DerivativeImage($derivativeParams[$i], $tplvar['TN_SRC']);
          $tplvar['my_derivative_url']=$current_derivative->get_url();
...
but I don't know how to set $derivativeParams[$i]

Do you think that's ok ?


To get a better help : Politeness like Hello-A link-Your past actions precisely described
Check my extensions : more than 30 available
who I am and what I do : http://fr.gravatar.com/flop25
My gallery : an illustration of how to integrate Piwigo in your website

Offline

 

#9 2012-01-30 16:55:32

rvelices
Piwigo Team
2005-12-29
1960

Re: Multi size : theme integration

ok. it's getting better. you are making a theme.
I think because you are in a theme, there should be no need for such thing as local_head, prefilter or events ....

can you tell me what the algo would be to compute $conf_thumbnail_width[$i] ?

while I wait for your algo, you could use:

{define_derivative height=100 width=9999} -> all images will have the same height
{define_derivative height=100 width=512 crop=true min_height=100 min_width=10 } -> all images will have the same height; width will be no larger than 512. If the width was larger than 512 (extreme panorama for example), the image will be cropped so that the resulting size will be exaclty 512x100

Offline

 

#10 2012-01-30 17:12:04

flop25
Piwigo Team
2006-07-06
7037

Re: Multi size : theme integration

rvelices wrote:

ok. it's getting better. you are making a theme.
I think because you are in a theme, there should be no need for such thing as local_head, prefilter or events ....

In order to be compatible with most of extension and to have a minimal maintenance between piwigo upgrades, it's better to do not have tpl files over-reading/writing the default ones.

rvelices wrote:

can you tell me what the algo would be to compute $conf_thumbnail_width[$i] ?

that's just the default config of the theme : here in that example 3 sizes so there is just $conf_thumbnail_width[1/2/3]

rvelices wrote:

while I wait for your algo, you could use:
{define_derivative}

The method that I thought and that you might think too, is to set {define_derivative  name='One' width=$conf_thumbnail_width[1]... with conf_thumbnail_width previously assigned.
Then
{foreach from=$thumbnails item=thumbnail name=thumbnail _loop}
{if $smarty.foreach.foo.index  == 1}<img src="{$pwg->derivative_url($One, $thumbnail.src_image)}">
...
But I do prefer a full php solution

btw that's great that we can use min_ parameters


To get a better help : Politeness like Hello-A link-Your past actions precisely described
Check my extensions : more than 30 available
who I am and what I do : http://fr.gravatar.com/flop25
My gallery : an illustration of how to integrate Piwigo in your website

Offline

 

#11 2012-02-03 13:48:05

flop25
Piwigo Team
2006-07-06
7037

Re: Multi size : theme integration

hello again ^^
what do the recent commits change in that practical case ?


To get a better help : Politeness like Hello-A link-Your past actions precisely described
Check my extensions : more than 30 available
who I am and what I do : http://fr.gravatar.com/flop25
My gallery : an illustration of how to integrate Piwigo in your website

Offline

 

#12 2012-02-03 15:58:01

rvelices
Piwigo Team
2005-12-29
1960

Re: Multi size : theme integration

flop25 wrote:

what do the recent commits change in that practical case ?

nothing really. I'm thinking about it, but honestly I'm against it because I think the way it is now is more powerful and optimized.

Offline

 

#13 2012-02-04 16:58:33

flop25
Piwigo Team
2006-07-06
7037

Re: Multi size : theme integration

rvelices wrote:

flop25 wrote:

what do the recent commits change in that practical case ?

nothing really. I'm thinking about it, but honestly I'm against it because I think the way it is now is more powerful and optimized.

ok I understand, you said -not directly- that you didn't want to change the way the url is display in tpl.
I just would like you explain to me how to set proprely the derivative parameters by php, plz. In order to understand and to explain later, and for updating themes too
thx

Last edited by flop25 (2012-02-04 16:58:55)


To get a better help : Politeness like Hello-A link-Your past actions precisely described
Check my extensions : more than 30 available
who I am and what I do : http://fr.gravatar.com/flop25
My gallery : an illustration of how to integrate Piwigo in your website

Offline

 

#14 2012-02-08 17:36:21

P@t
Piwigo Team
Nice
2007-06-13
4098

Re: Multi size : theme integration

rvelices wrote:

{define_derivative height=100 width=9999} -> all images will have the same height
{define_derivative height=100 width=512 crop=true min_height=100 min_width=10 } -> all images will have the same height; width will be no larger than 512. If the width was larger than 512 (extreme panorama for example), the image will be cropped so that the resulting size will be exaclty 512x100

In GThumb+, I need fixed height for thumbnails... but this does not work... I get a "Too big" error.


P@t

Offline

 

#15 2012-02-08 19:39:59

rvelices
Piwigo Team
2005-12-29
1960

Re: Multi size : theme integration

P@t wrote:

rvelices wrote:

{define_derivative height=100 width=9999} -> all images will have the same height
{define_derivative height=100 width=512 crop=true min_height=100 min_width=10 } -> all images will have the same height; width will be no larger than 512. If the width was larger than 512 (extreme panorama for example), the image will be cropped so that the resulting size will be exaclty 512x100

In GThumb+, I need fixed height for thumbnails... but this does not work... I get a "Too big" error.

because as said on the forum, I added the following test in i.php

Code:

    $greatest = ImageStdParams::get_by_type(IMG_XXLARGE);
    if ($params->max_width() > $greatest->max_width() || $params->max_height() > $greatest->max_height())
    {
      ierror('Too big', 403);
    }

maybe :
a. we remove the test ?
b. change || to && ?
c. or modify ImageStdParams::get_custom and make sure w/h is no larger than xxlarge ?

Offline

 
  •  » Engine
  •  » Multi size : theme integration

Board footer

Powered by FluxBB

github twitter newsletter Donate Piwigo.org © 2002-2022 · Contact