Blame view

backend/components/views/image_sizer.php 1.41 KB
f7ab7644   Mihail   after merge with ...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
  <?php
  /**
   * Created by PhpStorm.
   * User: vitaliy
   * Date: 05.10.15
   * Time: 16:20
   */
  use yii\helpers\Html;
  $this->registerJsFile('@web/js/vendor/bower/jquery-file-upload/js/vendor/jquery.ui.widget.js');
  $this->registerJsFile('@web/js/vendor/bower/jquery-file-upload/js/jquery.iframe-transport.js');
  $this->registerJsFile('@web/js/vendor/bower/jquery-file-upload/js/jquery.fileupload.js');
  
  ?>
  
df629228   Mihail   console csv parsing
15
  <?= $form->field( new \backend\models\ImageSizerForm(), 'file')->fileInput(['id'=>$field, 'data-url'=>"/admin/site/download-photo"]); ?>
f7ab7644   Mihail   after merge with ...
16
17
18
19
20
21
22
23
24
25
26
27
  
  <?= $form->field($model,$field)->hiddenInput(['id' => "{$field}_picture_link"]) ?>
  
  <div id="<?= $field?>_img_block">
      <?= $model->$field ? Html::img('/'.$model->$field): '' ?>
  </div>
  
  <script>
      $(function(){
  
          $("#<?= $field?>").fileupload({
              dataType: 'json',
df629228   Mihail   console csv parsing
28
              ImageSizerForm: {
f7ab7644   Mihail   after merge with ...
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
                  height: <?=$height?>,
                  width: <?= $width?>
              },
              done: function (e, data) {
                  var host = window.location.host.toString();
                  console.log(host);
                  console.log(data.result.link);
                  var img = '<img src="http://'+host+data.result.link+'">';
                  var block = $("#<?= $field?>_img_block");
                  block.find('img').remove();
                  block.append(img);
                  $("#<?= $field?>_picture_link").val(data.result.link);
              }
          });
  
      })
  </script>