Javascript-форум (https://javascript.ru/forum/)
-   Общие вопросы Javascript (https://javascript.ru/forum/misc/)
-   -   JS выбор изображения (https://javascript.ru/forum/misc/49607-js-vybor-izobrazheniya.html)

lepeed 20.08.2014 22:53

JS выбор изображения
 
Ребят, помогите пожалуйста. Использую YII-фреймворк и расширение для загрузки изображение через аякс.
<?php
    $this->widget('ext.EFineUploader.EFineUploader', array(
        'id' => 'FineUploader',
        'config' => array(
            'multiple' => true,
            'autoUpload' => true,
            'request' => array(
                'endpoint' => Yii::app()->createUrl('market/upload'),
                'params' => array('YII_CSRF_TOKEN' => Yii::app()->request->csrfToken),
            ),
            'retry' => array('enableAuto' => true, 'preventRetryResponseProperty' => true),
            'chunking' => array('enable' => true, 'partSize' => 100), //bytes
            'callbacks' => array(
                'onComplete'=>"js:function(id, fileName, responseJSON){
                                          var filename = responseJSON['filename'];
                                          
                                          var success = responseJSON['success'];
                                            if(success == true)
                                            {
jQuery('#image').append('<input name=\'image[]\' type=\'hidden\' value=\''+filename+'\'>');
                                                 jQuery('.reg_div_new .uploadClass').append(filename);
                                                 jQuery('.reg_div_new .deleteImage').removeClass('displaynone');
                                                 jQuery('.reg_div_new #image').val(filename);
                                                 jQuery('#uploadFile_new .qq-upload-button input').attr('disabled','disabled'); 
jQuery('#image').append('<img class=\'resize\' height=\'100px\' width=\'100px\' src=" . Yii::app()->baseUrl . '/images/upload/' . "'+filename+'></div>')

                                            }else{
                                                 jQuery('.reg_div_new #image').val('');
                                                 jQuery('.reg_div_new .uploadClass').append('');
                                                 jQuery('.reg_div_new .uploadClass').addClass('displaynone');
                                                 jQuery('.reg_div_new .deleteImage').addClass('displaynone');
                                                 jQuery('#uploadFile_new .qq-upload-button input').removeAttr('disabled','disabled'); 
                                            }
                                    }",
                 'messages'=>array(
                                         'typeError'=>"{file} has invalid extension. Only {extensions} are allowed.",
                                         'sizeError'=>"{file} is too large, maximum file size is {sizeLimit}.",
                                         'minSizeError'=>"{file} is too small, minimum file size is {minSizeLimit}.",
                                         'emptyError'=>"{file} is empty, please select files again without it.",
                                         'onLeave'=>"The files are being uploaded, if you leave now the upload will be cancelled."
                                        ),
                       'showMessage'=>"js:function(message){ alert(message); }",
                //'onError'=>"js:function(id, name, errorReason){ }",
                'onValidateBatch' => 'js:function(id, name, errorReason){ return true; }'
            ),
            'validation' => array(
                'allowedExtensions' => array('jpg', 'jpeg', 'gif'),
                'sizeLimit' => 2 * 1024 * 1024, //maximum file size in bytes
            //  'minSizeLimit'=>2*1024*1024,// minimum file size in bytes
            ),
        )
    ));
    ?>

вот такое вот во вьюхе новости:
<?php
foreach($images as $image) {
    echo CHtml::image('/images/upload/'.$image->filename, null, array("id"=>$image->id));
}
?>

а такое во вьюхе листинга новостей:
<div class="image">
	             <?php echo CHtml::image(Yii::app()->baseUrl."/images/upload/".$data->image); ?>
	             <br />
                     </div>


Человек загружает изображения, ему показываются они, среди них он выбирает "главное", которое пойдет в листинг новостей, остальные изображение выводятся в самой новости. Как это сделать? Помогите пожалуйста


Часовой пояс GMT +3, время: 23:35.