Browse Source

[backend] Produits : correction bug url photo

dev
Guillaume Bourgeois 4 years ago
parent
commit
777677bd49
2 changed files with 6 additions and 4 deletions
  1. +3
    -2
      backend/views/product/_form.php
  2. +3
    -2
      backend/views/product/index.php

+ 3
- 2
backend/views/product/_form.php View File

<?= $form->field($model, 'photo')->fileInput() ?> <?= $form->field($model, 'photo')->fileInput() ?>
<?php <?php
if (strlen($model->photo)) { if (strlen($model->photo)) {
$url = Yii::$app->urlManagerProducer->getHostInfo() . '/' . Yii::$app->urlManagerProducer->baseUrl;
echo '<img class="photo-product" src="' . $url . '/uploads/' . $model->photo . '" width="200px" /><br />';
$url = Yii::$app->urlManagerProducer->getHostInfo() . '/' . Yii::$app->urlManagerProducer->baseUrl . '/uploads/' . $model->photo;
$url = str_replace('//uploads','/uploads', $url) ;
echo '<img class="photo-product" src="' . $url . '" width="200px" /><br />';
echo '<input type="checkbox" name="delete_photo" id="delete_photo" /> <label for="delete_photo">Supprimer la photo</label><br /><br />'; echo '<input type="checkbox" name="delete_photo" id="delete_photo" /> <label for="delete_photo">Supprimer la photo</label><br /><br />';
} }
?> ?>

+ 3
- 2
backend/views/product/index.php View File

'filter' => '', 'filter' => '',
'value' => function ($model) { 'value' => function ($model) {
if (strlen($model->photo)) { if (strlen($model->photo)) {
$url = Yii::$app->urlManagerProducer->getHostInfo() . '/' . Yii::$app->urlManagerProducer->baseUrl;
return '<img class="photo-product" src="' . $url . '/uploads/' . $model->photo . '" />';
$url = Yii::$app->urlManagerProducer->getHostInfo() . '/' . Yii::$app->urlManagerProducer->baseUrl . '/uploads/'.$model->photo ;
$url = str_replace('//uploads','/uploads', $url) ;
return '<img class="photo-product" src="' . $url . '" />';
} }
return ''; return '';
} }

Loading…
Cancel
Save