Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Bricolage: users

find_or_create_alternate just returns the original image

 

 

Bricolage users RSS feed   Index | Next | Previous | View Threaded


bret at pectopah

Apr 8, 2011, 3:10 PM

Post #1 of 10 (1068 views)
Permalink
find_or_create_alternate just returns the original image

Hi everybody,

I'm just starting to use the find_or_create_alternate() method to make
thumbnails, and I must be doing something wrong. When I try something
like this:

my $size = 240;
my $thumb = $pic->find_or_create_alternate({
title_prefix => '',
title_suffix => '-' . $size,
file_suffix => '_sized_nicely,
et_key_name => 'auto_generated_image',
relate => 0,
transformer => sub {
shift->scale( xpixels => $element_names_and_sizes{$size} );
},
});

...no new media document is created, and the $thumb returned is the
original $pic. Any idea what I'm doing incorrectly?


Thanks,

Bret



--
Bret Dawson
Producer
Pectopah Productions Inc.
(416) 895-7635
bret [at] pectopah
www.pectopah.com


david at kineticode

Apr 9, 2011, 9:06 AM

Post #2 of 10 (1021 views)
Permalink
Re: find_or_create_alternate just returns the original image [In reply to]

On Apr 8, 2011, at 3:10 PM, Bret Dawson wrote:

> Hi everybody,
>
> I'm just starting to use the find_or_create_alternate() method to make
> thumbnails, and I must be doing something wrong. When I try something
> like this:
>
> my $size = 240;
> my $thumb = $pic->find_or_create_alternate({
> title_prefix => '',
> title_suffix => '-' . $size,
> file_suffix => '_sized_nicely,
> et_key_name => 'auto_generated_image',
> relate => 0,
> transformer => sub {
> shift->scale( xpixels => $element_names_and_sizes{$size} );
> },
> });
>
> ...no new media document is created, and the $thumb returned is the
> original $pic. Any idea what I'm doing incorrectly?

Is $pic a auto_generated_image already?

Best,

David


david at kineticode

Apr 9, 2011, 9:06 AM

Post #3 of 10 (1029 views)
Permalink
Re: find_or_create_alternate just returns the original image [In reply to]

On Apr 8, 2011, at 3:10 PM, Bret Dawson wrote:

> Hi everybody,
>
> I'm just starting to use the find_or_create_alternate() method to make
> thumbnails, and I must be doing something wrong. When I try something
> like this:
>
> my $size = 240;
> my $thumb = $pic->find_or_create_alternate({
> title_prefix => '',
> title_suffix => '-' . $size,
> file_suffix => '_sized_nicely,
> et_key_name => 'auto_generated_image',
> relate => 0,
> transformer => sub {
> shift->scale( xpixels => $element_names_and_sizes{$size} );
> },
> });
>
> ...no new media document is created, and the $thumb returned is the
> original $pic. Any idea what I'm doing incorrectly?

Is $pic a auto_generated_image already?

Best,

David


bret at pectopah

Apr 9, 2011, 10:18 AM

Post #4 of 10 (1026 views)
Permalink
Re: find_or_create_alternate just returns the original image [In reply to]

Hi David,

> Is $pic a auto_generated_image already?

No, it's just an "image". Do they need to be the same type?


Thanks,

Bret



On Sat, 2011-04-09 at 09:06 -0700, David E. Wheeler wrote:
> On Apr 8, 2011, at 3:10 PM, Bret Dawson wrote:
>
> > Hi everybody,
> >
> > I'm just starting to use the find_or_create_alternate() method to make
> > thumbnails, and I must be doing something wrong. When I try something
> > like this:
> >
> > my $size = 240;
> > my $thumb = $pic->find_or_create_alternate({
> > title_prefix => '',
> > title_suffix => '-' . $size,
> > file_suffix => '_sized_nicely,
> > et_key_name => 'auto_generated_image',
> > relate => 0,
> > transformer => sub {
> > shift->scale( xpixels => $element_names_and_sizes{$size} );
> > },
> > });
> >
> > ...no new media document is created, and the $thumb returned is the
> > original $pic. Any idea what I'm doing incorrectly?
>

>
> Best,
>
> David
>
>

--
Bret Dawson
Producer
Pectopah Productions Inc.
(416) 895-7635
bret [at] pectopah
www.pectopah.com


bret at pectopah

Apr 9, 2011, 10:18 AM

Post #5 of 10 (1026 views)
Permalink
Re: find_or_create_alternate just returns the original image [In reply to]

Hi David,

> Is $pic a auto_generated_image already?

No, it's just an "image". Do they need to be the same type?


Thanks,

Bret



On Sat, 2011-04-09 at 09:06 -0700, David E. Wheeler wrote:
> On Apr 8, 2011, at 3:10 PM, Bret Dawson wrote:
>
> > Hi everybody,
> >
> > I'm just starting to use the find_or_create_alternate() method to make
> > thumbnails, and I must be doing something wrong. When I try something
> > like this:
> >
> > my $size = 240;
> > my $thumb = $pic->find_or_create_alternate({
> > title_prefix => '',
> > title_suffix => '-' . $size,
> > file_suffix => '_sized_nicely,
> > et_key_name => 'auto_generated_image',
> > relate => 0,
> > transformer => sub {
> > shift->scale( xpixels => $element_names_and_sizes{$size} );
> > },
> > });
> >
> > ...no new media document is created, and the $thumb returned is the
> > original $pic. Any idea what I'm doing incorrectly?
>

>
> Best,
>
> David
>
>

--
Bret Dawson
Producer
Pectopah Productions Inc.
(416) 895-7635
bret [at] pectopah
www.pectopah.com


david at kineticode

Apr 9, 2011, 1:49 PM

Post #6 of 10 (1021 views)
Permalink
Re: find_or_create_alternate just returns the original image [In reply to]

On Apr 9, 2011, at 10:18 AM, Bret Dawson wrote:

> No, it's just an "image". Do they need to be the same type?

No, they should not be. I'm not sure, you'll have to debug it, I'm afraid. Finding an existing auto_generated_image is the only path to an early return I can see in the method. You're getting back exactly the same object?

Oh, wait, is it a Bric::Biz::Asset::Business::Media::Image? Only an Image object implements the needed functionality.

Best,

David


david at kineticode

Apr 9, 2011, 1:49 PM

Post #7 of 10 (1023 views)
Permalink
Re: find_or_create_alternate just returns the original image [In reply to]

On Apr 9, 2011, at 10:18 AM, Bret Dawson wrote:

> No, it's just an "image". Do they need to be the same type?

No, they should not be. I'm not sure, you'll have to debug it, I'm afraid. Finding an existing auto_generated_image is the only path to an early return I can see in the method. You're getting back exactly the same object?

Oh, wait, is it a Bric::Biz::Asset::Business::Media::Image? Only an Image object implements the needed functionality.

Best,

David


bret at pectopah

Apr 9, 2011, 2:46 PM

Post #8 of 10 (1021 views)
Permalink
Re: find_or_create_alternate just returns the original image [In reply to]

> No, they should not be. I'm not sure, you'll have to debug it, I'm afraid. Finding an existing auto_generated_image is the only path to an early return I can see in the method. You're getting back exactly the same object?
>
> Oh, wait, is it a Bric::Biz::Asset::Business::Media::Image? Only an Image object implements the needed functionality.
>

Yeah, it is. Both "image" and "auto_generated_image" are image objects.
But yes, the object returned is the exact same one I'm calling
find_or_create_alternate() on.

I'll do some debugging and report back. Prepare to learn about a typo in
my template!

Thanks,

Bret


> Best,
>
> David

--
Bret Dawson
Producer
Pectopah Productions Inc.
(416) 895-7635
bret [at] pectopah
www.pectopah.com


rs at plusw

Apr 10, 2011, 10:51 AM

Post #9 of 10 (1020 views)
Permalink
Re: find_or_create_alternate just returns the original image [In reply to]

Hi,

I just started using this function two days ago and it works fine.
May be something wrong with $element_names_and_sizes{$size} ?

Am 09.04.2011 um 19:18 schrieb Bret Dawson:

> Hi David,
>
>> Is $pic a auto_generated_image already?
>
> No, it's just an "image". Do they need to be the same type?
>
>
> Thanks,
>
> Bret
>
>
>
> On Sat, 2011-04-09 at 09:06 -0700, David E. Wheeler wrote:
>> On Apr 8, 2011, at 3:10 PM, Bret Dawson wrote:
>>
>>> Hi everybody,
>>>
>>> I'm just starting to use the find_or_create_alternate() method to make
>>> thumbnails, and I must be doing something wrong. When I try something
>>> like this:
>>>
>>> my $size = 240;
>>> my $thumb = $pic->find_or_create_alternate({
>>> title_prefix => '',
>>> title_suffix => '-' . $size,
>>> file_suffix => '_sized_nicely,
>>> et_key_name => 'auto_generated_image',
>>> relate => 0,
>>> transformer => sub {
>>> shift->scale( xpixels => $element_names_and_sizes{$size} );
>>> },
>>> });
>>>
>>> ...no new media document is created, and the $thumb returned is the
>>> original $pic. Any idea what I'm doing incorrectly?
>>
>
>>
>> Best,
>>
>> David
>>
>>
>
> --
> Bret Dawson
> Producer
> Pectopah Productions Inc.
> (416) 895-7635
> bret [at] pectopah
> www.pectopah.com
>

Mit freundlichen Grüßen
Rolf Schaufelberger
Geschäftsführer

plusW GmbH
Vorstadtstr. 61 -67 Tel. 07181 47 47 305
73614 Schorndorf Fax. 07181 47 45 344

www.plusw.de
www.mypixler.com
www.calendrino.de


bret at pectopah

Apr 10, 2011, 1:19 PM

Post #10 of 10 (1023 views)
Permalink
Re: find_or_create_alternate just returns the original image [In reply to]

Hi everybody,

I just figured this out. The inital media document had a mixed-case
filename, but a lowercase URI format.

So the regex that was trying to change the initial image's URI into the
thumbnail's URI was failing to find the filename, which left the
"target" URI the same as the starter one. Then the lookup found the
image with the desired URI and returned the inital picture.

I've committed a patch and sent a pull request.


Cheers,

Bret


On Sun, 2011-04-10 at 19:51 +0200, Rolf Schaufelberger wrote:
> Hi,
>
> I just started using this function two days ago and it works fine.
> May be something wrong with $element_names_and_sizes{$size} ?
>
> Am 09.04.2011 um 19:18 schrieb Bret Dawson:
>
> > Hi David,
> >
> >> Is $pic a auto_generated_image already?
> >
> > No, it's just an "image". Do they need to be the same type?
> >
> >
> > Thanks,
> >
> > Bret
> >
> >
> >
> > On Sat, 2011-04-09 at 09:06 -0700, David E. Wheeler wrote:
> >> On Apr 8, 2011, at 3:10 PM, Bret Dawson wrote:
> >>
> >>> Hi everybody,
> >>>
> >>> I'm just starting to use the find_or_create_alternate() method to make
> >>> thumbnails, and I must be doing something wrong. When I try something
> >>> like this:
> >>>
> >>> my $size = 240;
> >>> my $thumb = $pic->find_or_create_alternate({
> >>> title_prefix => '',
> >>> title_suffix => '-' . $size,
> >>> file_suffix => '_sized_nicely,
> >>> et_key_name => 'auto_generated_image',
> >>> relate => 0,
> >>> transformer => sub {
> >>> shift->scale( xpixels => $element_names_and_sizes{$size} );
> >>> },
> >>> });
> >>>
> >>> ...no new media document is created, and the $thumb returned is the
> >>> original $pic. Any idea what I'm doing incorrectly?
> >>
> >
> >>
> >> Best,
> >>
> >> David
> >>
> >>
> >
> > --
> > Bret Dawson
> > Producer
> > Pectopah Productions Inc.
> > (416) 895-7635
> > bret [at] pectopah
> > www.pectopah.com
> >
>
> Mit freundlichen Grüßen
> Rolf Schaufelberger
> Geschäftsführer
>
> plusW GmbH
> Vorstadtstr. 61 -67 Tel. 07181 47 47 305
> 73614 Schorndorf Fax. 07181 47 45 344
>
> www.plusw.de
> www.mypixler.com
> www.calendrino.de
>
>
>
>
>
>
>

--
Bret Dawson
Producer
Pectopah Productions Inc.
(416) 895-7635
bret [at] pectopah
www.pectopah.com

Bricolage users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.