Ignore:
Timestamp:
2008-08-13T20:35:13+12:00 (16 years ago)
Author:
ak19
Message:

Changes to make it compatible with multilingual filenames. Uses URL encoding for this.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gsdl/trunk/perllib/plugins/ImageConverter.pm

    r16521 r16771  
    181181    }
    182182
     183    # Images that will get generated may contain percent signs in their src filenames
     184    # Encode those percent signs themselves so that urls to the imgs refer to them correctly
     185    my $url_to_filehead = $filehead;
     186    $url_to_filehead =~ s/%/%25/g;
     187    my $url_to_filename_no_path = $filename_no_path;
     188    $url_to_filename_no_path =~ s/%/%25/g;
     189
    183190    # Convert the image to a new type (if required).
    184191    my $converttotype = $self->{'converttotype'};
     
    186193
    187194    if ($converttotype ne "" && $filename_full_path !~ m/$converttotype$/) {
    188    
     195    #    $doc_obj->add_utf8_metadata($section, "Image", $utf8_filename_meta);
     196
    189197    my $result = $self->convert($filename_full_path, $converttotype, "", "");
    190198    ($filename_full_path) = ($result =~ /=>(.*\.$converttotype)/);
     
    192200    $type = $converttotype;
    193201    $filename_no_path = "$filehead.$type";
     202    $url_to_filename_no_path = "$url_to_filehead.$type";
    194203    }
    195204
    196205    # add Image metadata
    197     $doc_obj->add_utf8_metadata($section, "Image", $filename_no_path);
     206    $doc_obj->add_utf8_metadata($section, "Image", $url_to_filename_no_path); # url to generated image
    198207
    199208    # here we overwrite the original with the potentially converted one
    200     $doc_obj->set_utf8_metadata_element($section, "Source", $filename_no_path);
     209    $doc_obj->set_utf8_metadata_element($section, "Source", $filename_no_path); # name of generated image
    201210
    202211    # use identify to get info about the (possibly converted) image
     
    225234
    226235    if ($self->{'create_thumbnail'} eq "true") {
    227     $self->create_thumbnail($filename_full_path, $filehead, $doc_obj, $section, $assocfilemeta);
     236    $self->create_thumbnail($filename_full_path, $filehead, $doc_obj, $section, $assocfilemeta, $url_to_filehead);
    228237    }
    229238    if ($self->{'create_screenview'} eq "true") {
    230     $self->create_screenview($filename_full_path, $filehead, $doc_obj, $section, $assocfilemeta);
     239    $self->create_screenview($filename_full_path, $filehead, $doc_obj, $section, $assocfilemeta, $url_to_filehead);
    231240    }
    232241}
     
    234243sub create_thumbnail {
    235244    my $self = shift(@_);
    236     my ($original_file, $filehead, $doc_obj, $section, $assocfilemeta) = @_;
     245    my ($original_file, $filehead, $doc_obj, $section, $assocfilemeta, $url_to_filehead) = @_;
     246    $url_to_filehead = $filehead unless defined $url_to_filehead;
    237247
    238248    my $thumbnailsize = $self->{'thumbnailsize'};
     
    246256    if (-e "$thumbnailfile") {
    247257    $doc_obj->associate_file("$thumbnailfile", $filehead."_thumb.$thumbnailtype",
    248                  "image/$thumbnailtype",$section);
     258                 "image/$thumbnailtype",$section); # name of generated image
    249259    $doc_obj->add_metadata ($section, "ThumbType", $thumbnailtype);
    250     $doc_obj->add_utf8_metadata ($section, "Thumb", $filehead."_thumb.$thumbnailtype");
     260    $doc_obj->add_utf8_metadata ($section, "Thumb", $url_to_filehead."_thumb.$thumbnailtype"); # url to generated image
    251261   
    252262    $doc_obj->add_metadata ($section, "thumbicon", "<img src=\"_httpprefix_/collect/[collection]/index/assoc/$assocfilemeta/[Thumb]\" width=[ThumbWidth] height=[ThumbHeight]>");
     
    268278   
    269279    my $self = shift(@_);
    270     my ($original_file, $filehead, $doc_obj, $section, $assocfilemeta) = @_;
     280    my ($original_file, $filehead, $doc_obj, $section, $assocfilemeta, $url_to_filehead) = @_;
     281    $url_to_filehead = $filehead unless defined $url_to_filehead;
    271282
    272283    # To do: if the actual image smaller than the screenview size,
     
    283294    #add the screenview as an associated file ...
    284295    if (-e "$screenviewfilename") {
    285     $doc_obj->associate_file("$screenviewfilename", $filehead."_screen.$screenviewtype", "image/$screenviewtype",$section);
     296    $doc_obj->associate_file("$screenviewfilename", $filehead."_screen.$screenviewtype", "image/$screenviewtype",$section); # name of generated image
    286297    $doc_obj->add_metadata ($section, "ScreenType", $screenviewtype);
    287     $doc_obj->add_utf8_metadata ($section, "Screen", $filehead."_screen.$screenviewtype");
     298    $doc_obj->add_utf8_metadata ($section, "Screen", $url_to_filehead."_screen.$screenviewtype"); # url to generated image
    288299   
    289300    $doc_obj->add_metadata ($section, "screenicon", "<img src=\"_httpprefix_/collect/[collection]/index/assoc/$assocfilemeta/[Screen]\" width=[ScreenWidth] height=[ScreenHeight]>");
Note: See TracChangeset for help on using the changeset viewer.