Announcement

  •  » Themes
  •  » [2.4] [multisize] Theme adaptations

#1 2012-05-01 21:29:28

Zaphod
Former Piwigo Team
2006-11-13
441

[2.4] [multisize] Theme adaptations

Hi everyone,

In order to update my themes for Piwigo 2.4 I need some clues about how to integrate multisize into my templates.

1) First, in Piwigo 2.3 I used in thumbnails.tpl this value:
{$thumbnail.FILE_PATH}
Which was the path of the image to be displayed if we'd click on the thumbnail.
This doesn't work anymore.

Now there are several derivatives for each image, how to access to a chosen derivative path from the thumbnail?

2) In stripped-galleria, I have to access all the data from the thumbnail page.
So, in addition to the {$thumbnail.FILE_PATH} I need, I also need to access to HD picture so I used two things:

-> {$thumbnail.FILE_HAS_HD} which doesn't work anymore. What is the equivalent now?

-> {$thumbnail.HD_PATH} which was generated by php in themeconf.inc.php:

Code:

add_event_handler('loc_end_index_thumbnails', 'add_thumbnails_high_url', 50, 2);
function add_thumbnails_high_url($tpl_var, $pictures)
{
  include_once(PHPWG_ROOT_PATH.'include/functions_picture.inc.php');
  foreach($tpl_var as $key => $value)
  {
    if ($value['FILE_HAS_HD'])
    {
      $tpl_var[$key]['HD_PATH'] = get_high_path($pictures[$key]);
    }
  }
  return $tpl_var;
}

How can I update this code to work again?

3) For stripped preload system I used a php code with this line:

Code:

$picturenext[$in]['image_url'] = get_image_url( $picturenext[$in] );

How to get access to a chosen derivative url at this point?



Thanks to anyone who will be able to help me!

Offline

 

#2 2012-05-01 21:46:37

rvelices
Former Piwigo Team
2005-12-29
1960

Re: [2.4] [multisize] Theme adaptations

1+2 try $thumbnail.src_image->get_url()

3. ? what's picturenext ?

Offline

 

#3 2012-05-01 21:52:20

Zaphod
Former Piwigo Team
2006-11-13
441

Re: [2.4] [multisize] Theme adaptations

rvelices wrote:

1+2 try $thumbnail.src_image->get_url()

Yes but this is the source image url, not the derivative one?
I really need to have the url of the image I want to diplay.

In stripped-galleria, for example, all the gallery is generated from the thumbnails page.
So I need to access directly a specific derivative url (like 'xlarge' url for example).

rvelices wrote:

3. ? what's picturenext ?

It's something I assign afterwards to the template, to make image preload possible.

Offline

 

#4 2012-05-01 22:09:11

Zaphod
Former Piwigo Team
2006-11-13
441

Re: [2.4] [multisize] Theme adaptations

Another problem, this value seems not to be available anymore

Code:

{$thumbnail.ID}

Offline

 

#5 2012-05-01 22:39:26

rvelices
Former Piwigo Team
2005-12-29
1960

Re: [2.4] [multisize] Theme adaptations

Zaphod wrote:

rvelices wrote:

1+2 try $thumbnail.src_image->get_url()

Yes but this is the source image url, not the derivative one?
I really need to have the url of the image I want to diplay.

In stripped-galleria, for example, all the gallery is generated from the thumbnails page.
So I need to access directly a specific derivative url (like 'xlarge' url for example).

Just take a look a thumbnails.tpl ...
{assign var=derivative value=$pwg->derivative($derivative_params, $thumbnail.src_image)}
becomes
{assign var=my value=$pwg->derivative('xlarge', $thumbnail.src_image)}
than you can use $my->get_url(), $my->get_size() etc...

alternatively if you just need an url, use $pwg->derivative_url('xlarge', $thumbnail.src_image)

Offline

 

#6 2012-05-01 22:42:24

rvelices
Former Piwigo Team
2005-12-29
1960

Re: [2.4] [multisize] Theme adaptations

Zaphod wrote:

Another problem, this value seems not to be available anymore

Code:

{$thumbnail.ID}

use id lower case (you can get any db value ...)
by the way, why not use the admin multi view and click on Debug Template or just set this value from your local config ?
It will show you in a new window what is assigned to the template ...

Offline

 

#7 2012-05-01 23:14:29

flop25
Piwigo Team
2006-07-06
7037

Re: [2.4] [multisize] Theme adaptations

a doc is available at http://piwigo.org/doc/doku.php?id=dev:c … 2.4#how_to
basicly we need to define a custom size in each tpl and then assign it to handle it easier ; you get still get the path with get_path()

Last edited by flop25 (2012-05-01 23:15:58)


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

 

#8 2012-05-01 23:44:55

Zaphod
Former Piwigo Team
2006-11-13
441

Re: [2.4] [multisize] Theme adaptations

Ok thanks, I will try all this.
The functions I can use are the same in PHP than the ones in the templates?

Offline

 

#9 2012-05-02 09:48:48

flop25
Piwigo Team
2006-07-06
7037

Re: [2.4] [multisize] Theme adaptations

I've seen this
$derivative = new DerivativeImage($derivativeParams, new SrcImage($row));
[...]
$derivative->get_size();
so it's possible

edit you can also use
DerivativeImage::url(IMG_THUMB, $src_image) where IMG_THUMB is the type defined in derivative_std_params.inc.php
or also use DerivativeImage::thumb_url($row) where row is the result of a query SELECT id,path,representative_ext,name,date_creation,comment,author,level,file  FROM '.IMAGES_TABLE.' ...

Last edited by flop25 (2012-05-02 09:56:25)


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

 

#10 2012-05-02 22:16:45

Zaphod
Former Piwigo Team
2006-11-13
441

Re: [2.4] [multisize] Theme adaptations

With your help I managed to update stripped & stripped-galleria themes to do nearly what  want.
(I'll publish stripped theme beta2 this evening).

Offline

 

#11 2012-05-02 22:48:07

Zaphod
Former Piwigo Team
2006-11-13
441

Re: [2.4] [multisize] Theme adaptations

I used this:

flop25 wrote:

I've seen this
$derivative = new DerivativeImage($derivativeParams, new SrcImage($row));
$derivative->get_url();

in themeconf.inc.php and it works perfectly.

Now that I understand how the derivative work... the next step is to manage to choose automatically the best derivative for the screen (and that would be able to replace the autosize function of stripped)
But this will wait a little.

Offline

 

#12 2012-05-02 22:50:49

flop25
Piwigo Team
2006-07-06
7037

Re: [2.4] [multisize] Theme adaptations

Zaphod wrote:

I used this:

flop25 wrote:

I've seen this
$derivative = new DerivativeImage($derivativeParams, new SrcImage($row));
$derivative->get_url();

in themeconf.inc.php and it works perfectly.

Now that I understand how the derivative work... the next step is to manage to choose automatically the best derivative for the screen (and that would be able to replace the autosize function of stripped)
But this will wait a little.

[Forum, topic 19253] Multi size : size for the picture page ^^

Last edited by flop25 (2012-05-02 22:51:37)


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

 

#13 2012-05-02 22:55:05

Zaphod
Former Piwigo Team
2006-11-13
441

Re: [2.4] [multisize] Theme adaptations

Yes I know about this.
This would be great, even if I don't realize how much work it would need.
I think it would not be so difficult to implement it in a theme, but I still don't know how to code a plugin...

Offline

 

#14 2012-08-07 22:42:18

Zaphod
Former Piwigo Team
2006-11-13
441

Re: [2.4] [multisize] Theme adaptations

Zaphod wrote:

2) In stripped-galleria, I have to access all the data from the thumbnail page.
So, in addition to the {$thumbnail.FILE_PATH} I need, I also need to access to HD picture so I used two things:

-> {$thumbnail.FILE_HAS_HD} which doesn't work anymore. What is the equivalent now?

-> {$thumbnail.HD_PATH} which was generated by php in themeconf.inc.php:

Code:

add_event_handler('loc_end_index_thumbnails', 'add_thumbnails_high_url', 50, 2);
function add_thumbnails_high_url($tpl_var, $pictures)
{
  include_once(PHPWG_ROOT_PATH.'include/functions_picture.inc.php');
  foreach($tpl_var as $key => $value)
  {
    if ($value['FILE_HAS_HD'])
    {
      $tpl_var[$key]['HD_PATH'] = get_high_path($pictures[$key]);
    }
  }
  return $tpl_var;
}

How can I update this code to work again?

In fact, I still didn't update this part in stripped-galleria.
I dont' know how to do it.

The point is to have access to :
-> the fact the hd picture exists (has_hd)
-> the hd picture path
from the thumbnail page.

Last edited by Zaphod (2012-08-07 22:42:31)

Offline

 

#15 2012-08-09 09:32:12

rvelices
Former Piwigo Team
2005-12-29
1960

Re: [2.4] [multisize] Theme adaptations

Zaphod wrote:

In fact, I still didn't update this part in stripped-galleria.
I dont' know how to do it.

The point is to have access to :
-> the fact the hd picture exists (has_hd)
-> the hd picture path
from the thumbnail page.

There is no such thing as the HD in 2.4. Instead you can always access {$thumbnail.src_image} which is an object of type SrcImage (defined in derivatives.inc.php if you want to take a look att all possible function members). You can call {$thumbnail.src_image->get_url()}
I don't know what you want to do with it, but I strongly doubt you need it. The orginal src_image could for example be raw output from a camera always in landscape mode but with an orientation flag ...

Offline

 
  •  » Themes
  •  » [2.4] [multisize] Theme adaptations

Board footer

Powered by FluxBB

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