X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FDB%2FShopPart.pm;h=7c67bb1a367fe8b43a891526d66837c4621cc89a;hb=549f187d3a2b1d15f96c4556714666ed954447bb;hp=1df77fd8982f92efe895762bb48dae3b68ad7c2b;hpb=b2bedb6b5eff41a17ddb194df1c75213b841f3bb;p=kivitendo-erp.git diff --git a/SL/DB/ShopPart.pm b/SL/DB/ShopPart.pm index 1df77fd89..7c67bb1a3 100644 --- a/SL/DB/ShopPart.pm +++ b/SL/DB/ShopPart.pm @@ -50,16 +50,20 @@ sub get_tax_and_price { } sub get_images { - my ( $self ) = @_; + my ($self, %params) = @_; require SL::DB::ShopImage; my $images = SL::DB::Manager::ShopImage->get_all( where => [ 'files.object_id' => $self->{part_id}, ], with_objects => 'file', sort_by => 'position' ); my @upload_img = (); foreach my $img (@{ $images }) { my $file = SL::File->get(id => $img->file->id ); - my ($path, $extension) = (split /\./, $file->file_name); + # no good: split("\." , 202.220.pdf) -> invaild extension 220 + # file->extension should be in SL::File, a valid extension may also be 'tar.gz' + my ($path, $extension) = split(/\.([^\.]+)$/, $file->file_name); my $content = File::Slurp::read_file($file->get_file); - my $temp ={ ( link => 'data:' . $file->mime_type . ';base64,' . MIME::Base64::encode($content, ""), #$content, # MIME::Base64::encode($content), + + my $temp ={ ( + link => $params{want_binary} ? $content : 'data:' . $file->mime_type . ';base64,' . MIME::Base64::encode($content, ""), description => $img->file->title, position => $img->position, extension => $extension,