Beispiel #1
0
?>
                                </div>
                                <input type="file" class="fileupload-cover-front" name="CoverForm[photo]" value="" data-url="<?php 
echo Url::toRoute(['covers-api/upload-cover-front', 'id' => $cover->id]);
?>
">
                            </span>
                    </form>

                    <div id="coverFrontPreview">

                        <?php 
if (file_exists(UserUrl::coverFront(false, $cover->id) . DIRECTORY_SEPARATOR . UserUrl::imageFile($cover->cover_front, UserUrl::IMAGE_THUMB, 'png'))) {
    ?>
                            <div class="row"><div class="col-lg-3"><div class="thumbnail"><a class="thumbnail"><img src="<?php 
    echo UserUrl::coverFront(true, $cover->id) . DIRECTORY_SEPARATOR . UserUrl::imageFile($cover->cover_front, UserUrl::IMAGE_THUMB, 'png');
    ?>
" /></a></div></div></div>
                        <?php 
}
?>
                    </div>
                </div>




                <div class="form-group">

                    <form action="<?php 
echo Url::toRoute(['covers-api/upload-cover-back', 'id' => $cover->id]);
Beispiel #2
0



        <div class="bb-cover-wrapper">




            <div id="bb-cover" class="bb-bookblock" style="background: none;">

            <div class="bb-item" id="sitem1">
                <div class="content" >
                    <div class="box">
                        <div id="coverFrontBackground" style="width: 100%; height: 100%; border-bottom-right-radius: 5px; border-top-right-radius: 5px; position: absolute; background-size: cover; background-image: url('<?php 
echo UserUrl::coverFront(true, $selected_cover->id) . DIRECTORY_SEPARATOR . UserUrl::imageFile($selected_cover->cover_front, UserUrl::IMAGE_ORIGINAL, 'png');
?>
');">

                            <div class="cover-area" style="position: absolute; width: 100%; height: 100%; ">

                                <div id="coverWindowPreview" style="position: absolute;
                                    left:<?php 
echo $selected_cover->window_offset_x / 7.1;
?>
%;
                                    top:<?php 
echo $selected_cover->window_offset_y / 2.6;
?>
%;
                                    width:<?php 
Beispiel #3
0
 public function updateCoverFront()
 {
     //Удаляем старую подложку обложки
     foreach (UserUrl::$IMAGE_SIZE as $image_size => $value) {
         $file_path = UserUrl::coverFront(false, $this->id) . DIRECTORY_SEPARATOR . UserUrl::imageFile($this->cover_front, $image_size, 'png');
         if (file_exists($file_path)) {
             unlink($file_path);
         }
     }
     $file = UploadedFile::getInstance($this, 'photo');
     if ($file) {
         if ($file->size !== 0) {
             $file_id = AlphaId::id(rand(10000000000, 9999999999999));
             $file_path = UserUrl::coverFront(false, $this->id) . DIRECTORY_SEPARATOR . UserUrl::imageFile($file_id, UserUrl::IMAGE_ORIGINAL, 'png');
             $file->saveAs($file_path);
             foreach (UserUrl::$IMAGE_SIZE as $image_size => $param) {
                 if ($image_size == UserUrl::IMAGE_ORIGINAL) {
                     continue;
                 }
                 $image = Yii::$app->image->load($file_path);
                 $type = Yii\image\drivers\Image::WIDTH;
                 $file_resize_path = UserUrl::coverFront(false, $this->id) . DIRECTORY_SEPARATOR . UserUrl::imageFile($file_id, $image_size, 'png');
                 $image->resize($param['width'], $param['height'], $type);
                 $image->save($file_resize_path);
             }
             $this->cover_front = $file_id;
             if (!$this->save()) {
                 return ['error' => ['msg' => Yii::t('app', 'Ошибка записи в базу-данных')]];
             } else {
                 return ['response' => ['status' => true, 'cover_front' => $file_id, 'cover_front_thumb_url' => UserUrl::coverFront(true, $this->id) . DIRECTORY_SEPARATOR . UserUrl::imageFile($file_id, UserUrl::IMAGE_THUMB, 'png')]];
             }
         } else {
             return ['error' => ['msg' => Yii::t('app', 'Данные не получены')]];
         }
     } else {
         return ['error' => ['msg' => Yii::t('app', 'Данные не получены')]];
     }
 }