Beispiel #1
0
echo Yii::t('easyii', 'Image');
?>
</th>
        <th><?php 
echo Yii::t('easyii', 'Description');
?>
</th>
        <th width="150"></th>
    </tr>
    </thead>
    <tbody>
    <?php 
foreach ($photos as $photo) {
    ?>
        <?php 
    echo str_replace(['{{photo_id}}', '{{photo_thumb}}', '{{photo_image}}', '{{photo_description}}'], [$photo->primaryKey, Image::thumb($photo->image, Photo::PHOTO_THUMB_WIDTH, Photo::PHOTO_THUMB_HEIGHT), $photo->image, $photo->description], $photoTemplate);
    ?>
    <?php 
}
?>
    </tbody>
</table>
<p class="empty" style="display: <?php 
echo count($photos) ? 'none' : 'block';
?>
;"><?php 
echo Yii::t('easyii', 'No photos uploaded yet');
?>
.</p>

<?php 
Beispiel #2
0
use common\populac\widgets\Redactor;
$module = $this->context->module->id;
\common\populac\assets\AdminAsset::register($this);
$form = ActiveForm::begin(['enableAjaxValidation' => true, 'options' => ['enctype' => 'multipart/form-data', 'class' => 'model-form'], 'fieldConfig' => ['template' => "{label}\n<span class=\"col-md-10\">{input}</span>\n<span class=\"col-md-offset-2 col-md-10\">{error}</span>", 'labelOptions' => ['class' => 'col-md-2 control-label text-right']]]);
echo $form->field($model, 'title');
?>

<?php 
if ($this->context->module->settings['articleThumb']) {
    ?>
    <?php 
    if ($model->image) {
        ?>
        <div class="col-md-offset-2">
            <img src="<?php 
        echo Image::thumb($model->image, 240);
        ?>
">
            <a href="<?php 
        echo Url::to(['/populac/' . $module . '/items/clear-image', 'id' => $model->primaryKey]);
        ?>
"
               class="text-danger confirm-delete" title="<?php 
        echo Yii::t('easyii', 'Clear image');
        ?>
">
                <?php 
        echo Yii::t('easyii', 'Clear image');
        ?>
</a>
        </div>
Beispiel #3
0
 public function actionImage($id)
 {
     $success = null;
     if ($photo = Photo::findOne($id)) {
         $oldImage = $photo->image;
         $photo->image = UploadedFile::getInstance($photo, 'image');
         if ($photo->image && $photo->validate(['image'])) {
             $photo->image = Image::upload($photo->image, 'photos', Photo::PHOTO_MAX_WIDTH);
             if ($photo->image) {
                 if ($photo->save()) {
                     @unlink(Yii::getAlias('@webroot') . $oldImage);
                     $success = ['message' => Yii::t('easyii', 'Photo uploaded'), 'photo' => ['image' => $photo->image, 'thumb' => Image::thumb($photo->image, Photo::PHOTO_THUMB_WIDTH, Photo::PHOTO_THUMB_HEIGHT)]];
                 } else {
                     @unlink(Yii::getAlias('@webroot') . $photo->image);
                     $this->error = Yii::t('easyii', 'Update error. {0}', $photo->formatErrors());
                 }
             } else {
                 $this->error = Yii::t('easyii', 'File upload error. Check uploads folder for write permissions');
             }
         } else {
             $this->error = Yii::t('easyii', 'File is incorrect');
         }
     } else {
         $this->error = Yii::t('easyii', 'Not found');
     }
     return $this->formatResponse($success);
 }