I changed this whole functions in itemactions.php
public function uploadItemResources($aResources,$itemId) {
............................................
.........................................
........................................
unset($itemResourceManager);
}
return 0; // NO PROBLEMS
}
To this one
public function uploadItemResources($aResources,$itemId)
{
if($aResources != '') {
$wat = new Watermark();
$itemResourceManager = ItemResource::newInstance() ;
$numImagesItems = osc_max_images_per_item();
$numImages = $itemResourceManager->countResources($itemId);
foreach ($aResources['error'] as $key => $error) {
if($numImagesItems==0 || ($numImagesItems>0 && $numImages<$numImagesItems)) {
if ($error == UPLOAD_ERR_OK) {
$numImages++;
$tmpName = $aResources['tmp_name'][$key] ;
$itemResourceManager->insert(array(
'fk_i_item_id' => $itemId
)) ;
$resourceId = $itemResourceManager->dao->insertedId();
// Create normal size
$normal_path = $path = osc_content_path() . 'uploads/' . $resourceId . '.jpg' ;
$size = explode('x', osc_normal_dimensions()) ;
ImageResizer::fromFile($tmpName)->resizeTo($size[0], $size[1])->saveToFile($path) ;
if( osc_is_watermark_text() ) {
$wat->doWatermarkText( $path , osc_watermark_text_color(), osc_watermark_text() , 'image/jpeg' );
} elseif ( osc_is_watermark_image() ){
$wat->doWatermarkImage( $path, 'image/jpeg');
}
// Create preview
$path = osc_content_path(). 'uploads/' . $resourceId . '_preview.jpg' ;
$size = explode('x', osc_preview_dimensions()) ;
ImageResizer::fromFile($normal_path)->resizeTo($size[0], $size[1])->saveToFile($path) ;
// Create thumbnail
$path = osc_content_path(). 'uploads/' . $resourceId . '_thumbnail.jpg' ;
$size = explode('x', osc_thumbnail_dimensions()) ;
ImageResizer::fromFile($normal_path)->resizeTo($size[0], $size[1])->saveToFile($path) ;
if( osc_keep_original_image() ) {
$path = osc_content_path() . 'uploads/' . $resourceId.'_original.jpg' ;
move_uploaded_file($tmpName, $path) ;
}
$s_path = 'oc-content/uploads/' ;
$resourceType = 'image/jpeg' ;
$itemResourceManager->update(
array(
's_path' => $s_path
,'s_name' => osc_genRandomPassword()
,'s_extension' => 'jpg'
,'s_content_type' => $resourceType
)
,array(
'pk_i_id' => $resourceId
,'fk_i_item_id' => $itemId
)
) ;
osc_run_hook('uploaded_file', ItemResource::newInstance()->findByPrimaryKey($resourceId));
}
}
}
unset($itemResourceManager);
}
}
I thinks this is the only change i have made, If didn't forget something!!!
Sorry i spell imagick code instead of this change.
Regards