yii-starter-kit / yii2-starter-kit

Yii2 Starter Kit
http://yii2-starter-kit.terentev.net
Other
1.42k stars 648 forks source link

Article attachment and thumbnail upload location change. #779

Closed algsupport closed 2 years ago

algsupport commented 2 years ago

Hello, Thank you for this great kit. Some developers I hired used it to create a website for me and their implementation was not great. They somehow managed to store the full url (including the website hostname) of the attachment and thumbnail files being uploaded in an article. I don't know if this is by design of the kit or something the developers considered they needed to do.

If this is a feature of the kit, would you be able to let me know where can I set/change this? If it's not a part of this kit's functionality, do you have any ideas how can I track down where they have put that code?

Thank you for your time. Best Regards.

XzAeRo commented 2 years ago

Hi,

The hostname and the path of the uploads are stored separately, precisely to solve these cases.

I don't know how they implemented it, but you can try to check the codebase to see if they hardcoded it there, or in the database. Fixing the codebase should be easier, while reversing the database changes should be a bit more complicated.

I would suggest checking on common/models/Articles, backend/modules/ and the frontend views files.

Best regards.

algsupport commented 2 years ago

It's stored like this:

MariaDB [dbname]> select id,thumbnail_base_url,thumbnail_path from post where id =56;
+----+---------------------------------------------------+----------------------------------------+
| id | thumbnail_base_url                                | thumbnail_path                         |
+----+---------------------------------------------------+----------------------------------------+
| 56 | https://www.example.com/storage/web/source | 1/QJHrODN5_bd7a9Np4RAN8TmW3thBCEpt.png |
+----+---------------------------------------------------+----------------------------------------+

Reading the code, I believe this is do to the file-kit implementation. If so, is there a way to override this? My issue is that I am developing on a dev server and I am using it to also populate some articles, then I will sync with production and I will also sync the database.

This will cause the base_url of the dev server to be used. If the dev server in running, it will render the images, but that's not optimal.