Home > Enterprise >  Wysiwyg image is showing up in media/wysiwy not inside pub/media/wysiwyg. How do I fix this?
Wysiwyg image is showing up in media/wysiwy not inside pub/media/wysiwyg. How do I fix this?

Time:11-14

Okay so I have a Magento 2.4.5 project where I am facing some issues like images not loading up because they are being looked up inside pub/media/wysiwyg instead of media/wysiwyg. I have some wysiwyg images inside pub/media/wysiwyg/<some_image_directory>, however on the live site the directories and files are showing up as media/wysiwyg. How can I make sure that a separate pub/media/wysiwyg directory is created in the live site apart from the media directory that is already there such that the image loads up properly? We are using nginx which is opening up at 'pub' directory as the root where the media directory resides. Any help is appreciated.

I tried checking for the piece of code where the image is coming from in an attempt to see if the path can be changed programmatically by removing the 'pub/' part from the pub/media/wysiwyg/ for the live site. However, that is not something that can be done as that will change things project-wide, which might break other things. Hence that is not being done.

CodePudding user response:

First, you need to make sure that you are running the site from the root folder i.e. public_html on the server.

Steps to reproduce:

1: Run the command to load content:

bin/magento setup:static-content:deploy -f

2: Next command: chmod -R 777 pub/*

3: Set the secure base media URL and unsecure media URL from Magento database which you recently created and find the table core_config_data and change the path value as:

web/secure/base_media_url => https://example.com/pub/media/

web/unsecure/base_media_url => https://example.com/pub/media/

Or from Magento Admin

Stores -> Settings: Configuration -> General -> Base Url's -> Base URL for User Media Files

and to

Stores -> Settings: Configuration -> General -> Base Url's (Secure) -> Base URL for User Media Files

Flush Cache

4: Might be missing .htaccess in your /pub/media/ folder.

5: Check your .htaccess file, if there's bad code.

Thanks

CodePudding user response:

Okay so I figured out the issue.

I was running the website from the pub directory as I should however there was a third party plugin which had some hard-coded src set by the owner for images set as /pub/media/wysiwyg in the adminHtml since they were using an older version of Magento which used to place images inside /pub/media/wysiwyg instead.

So I just changed it to /media/wysiwyg over there and everything works as expected.

Tbh the whole issue was quite hacky as the owner seems to have put a script inside the third party module's description section in the adminHtml and is using hard-coded links such as this.

Thank you all for the comments. :)

  • Related