Index: openacs-4/packages/acs-subsite/www/shared/portrait-bits.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/www/shared/portrait-bits.tcl,v diff -u -N -r1.10.2.3 -r1.10.2.4 --- openacs-4/packages/acs-subsite/www/shared/portrait-bits.tcl 31 Dec 2015 17:35:48 -0000 1.10.2.3 +++ openacs-4/packages/acs-subsite/www/shared/portrait-bits.tcl 5 Jan 2016 14:55:50 -0000 1.10.2.4 @@ -13,7 +13,7 @@ # The size info is a valid geometry as provided for image magicks # "convert". We provide here a sample list of valid sizes # -if {$size ni {x24 x50 x100}} { +if {$size ne "" && $size ni {x24 x50 x100}} { ad_log warning "size '$size' is not supported" set size "" } @@ -26,28 +26,51 @@ } else { content::item::get -item_id $item_id -array_name itemInfo - if {$itemInfo(storage_type) eq "file"} { - # - # For portraits stored as files in the content repository, - # we provide cached thumbnails, which use in their cache - # key the revision id. - # + # + # For portraits stored as files in the content repository, + # we provide cached thumbnails, which use in their cache + # key the revision id. + # - set folder [acs_root_dir]/portrait-thumbnails - if {![file exists $folder]} { - file mkdir $folder - } + set folder [acs_root_dir]/portrait-thumbnails + if {![file exists $folder]} { + file mkdir $folder + } - set filename $folder/$itemInfo(revision_id).$size - - if {![file exists $filename]} { - set input_file [content::revision::get_cr_file_path -revision_id $itemInfo(revision_id)] - exec convert $input_file -resize $size $filename + set filename $folder/$itemInfo(revision_id).$size + + if {![file exists $filename]} { + switch $itemInfo(storage_type) { + "file" { + set input_file [content::revision::get_cr_file_path -revision_id $itemInfo(revision_id)] + exec convert $input_file -resize $size $filename + } + "lob" { + set input_file [ad_tmpnam] + set revision_id $itemInfo(revision_id) + # TODO: Oracle query and .xql is missing + db_blob_get_file write_lob_content { + select lob as content, 'lob' as storage_type + from cr_revisions + where revision_id = :revision_id + } -file $input_file + exec convert $input_file -resize $size $filename + file delete $input_file + } + default { + ad_log warning "unsupported storage type for portraits: $itemInfo(storage_type)" + } } - + } + # + # Test again if the file exists, we might have converted the + # file by the if-clause above. + # + if {[file exists $filename]} { ad_returnfile_background 200 $itemInfo(mime_type) $filename } else { - ad_log warning "Storage_type lob not handled" + ad_log warning "cannot show portrait with item_id $item_id for user $user_id " + ns_returnnotfound } } }