CostaRico / yii2-images

Yii2-images - behavior-based module for resizing, storing, caching and attaching images.
160 stars 97 forks source link

404, yii2 advanced, additional application #92

Open IljaPHP opened 5 years ago

IljaPHP commented 5 years ago

I can upload and see images by admin panel in back-end application without any problems and see images in the "frontend" yii2 application also, but I have an additional separate front-end application and I can't see images there. It's returns 404 error.

Take one image, for example, that has one URL in all applications, but all applications have different domain names.

My common/config/main.php :

'modules' => [
'yii2images' => [
'class' => 'rico\yii2images\Module',
//be sure, that permissions ok
//if you cant avoid permission errors you have to create "images" folder in web root manually and set 777 permissions
'imagesStorePath' => '@root/upload/store', //path to origin images
'imagesCachePath' => '@root/upload/cache', //path to resized copies
'graphicsLibrary' => 'GD', //but really its better to use 'Imagick'
'placeHolderPath' => '@root/upload/store/no-image.png', // if you want to get placeholder when image not exists, string will be processed by Yii::getAlias
'imageCompressionQuality' => 85, // Optional. Default value is 85.
]

Same code of Costa-Rico/images in all 3 models:

  public $gallery;
  public $gallery_url;

    public function behaviors()
    {
        return [
            'image' => [
                'class' => 'rico\yii2images\behaviors\ImageBehave',
            ]
        ];
    }

In the separate frontend application I trying to show image by with code:

   $general_logo =  General::find()->where(['index' => 'logo_social'])->one();
   if($general_logo) $image = $general_logo->getImage();
   if($general_logo && $image) : ?>
      <meta property="og:image" content="<?= $image->getUrl(); ?>"/>
   <?php endif; ?>

I was trying to use frontend\models\General and creating of own this_separate_application\models\General (ActiveRecord, same table) for this application.

How I can to solve this problem? Thank you.