如何使用Yii2 DetailView在后端渲染前端图像?

I want to render/show an image in a view on backend, but the image location is in frontend/web/uploads.

I tried doing this on the DetailView::widget():

...
[
    'attribute'=>'image',
    'value'=>('/frontend/web/uploads/'.$model->image),
    'format' => ['image',['width'=>'100','height'=>'100']],
],

But the image is not showing up. Any help?

If this is the only place where you're linking to frontend from backend, the easiest way would be defining alias in your backend config:

Yii::setAlias('@frontendUploads', 'https://repasca.devs/uploads');

And use this alias for building file URL:

[
    'attribute' => 'image',
    'value' => Yii::getAlias('@frontendUploads') . '/' . $model->image,
    'format' => ['image', ['width' => '100', 'height' => '100']],
],
use yii\helpers\Html;  

 [
      'label' => 'Image',
      'format' => 'raw',
      'value' => Html::img('@web/uploaded_images/' . $model->image, ['width' => '10px', 'height' => '10px']),
 ],

Yes it is possible to access frontend/web/uploads to backend view.

First add urlManagerFrontend in backend->config->main.php like

'components' => [
    'urlManagerFrontend' => [
        'class' => 'yii\web\urlManager',
        'baseUrl' => 'frontend/web/', //Access frontend web url
    ],
],

And then access the frontend/web/ to the backend like

Yii::$app->urlManagerFrontend->baseUrl.'/uploads/your_image.jpg'

In DetailView::widget like

[
   'attribute'=>'image',
   'value'=> function ($model) {
        return Html::img(Yii::$app->urlManagerFrontend->baseUrl.'/uploads/'.$model->image, ['alt' => 'No Image', 'width' => '10px', 'height' => '10px']);
   },
   'format' => 'raw',
],