-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Set media storage root to wysiwyg directory in pub/media #22681
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set media storage root to wysiwyg directory in pub/media #22681
Conversation
Hi @vishal-7037. Thank you for your contribution
For more details, please, review the Magento Contributor Assistant documentation |
@magento-engcom-team give me test instance |
Hi @vishal-7037. Thank you for your request. I'm working on Magento instance for you |
Hi @vishal-7037, here is your new Magento instance. |
Hi @sidolov, thank you for the review. |
✔️ QA passed |
22dd1be
to
0970c37
Compare
0970c37
to
04d926c
Compare
@magento-engcom-team give me test instance |
Hi @vishal-7037. Thank you for your request. I'm working on Magento instance for you |
Hi @vishal-7037, here is your new Magento instance. |
@Nazar65 ,I've checked this in the vanilla instance. and seems working fine. Please check here: https://www.screencast.com/t/B9qZnhTeh Thank you. |
@vishal-7037 There is not |
@Nazar65 , For that we have to chage path from
and also related changes... Can I proceed? Thanks. |
I think this issue is created for CMS parts (Pages/Blocks). So, I don't think we've to change for catalog section. What do you think? |
Ok, I started to look into this a bit. I think the change of the So we can't hardcode the path to use in that modal to What I did notice, is that if you already have a But I don't know if that would be enough? Shouldn't the root of the directory tree at the left side of that modal also not start from the directory you pass it? Instead of always starting from @sidolov, @Nazar65 or @danmooney2, what are your thoughts on this? @vishal-7037: are you still interested in trying to fix this issue if you get some more info? |
There are folders that are excluded from being shown in media gallery in Magento/Cms/etc/di.xml, so to say entire pub/media contents can be altered currently from media gallery is not correct. I empathize with both the fix and the current functionality. If we feel that #22681 (review) doesn't provide enough value to justify current functionality then we can proceed with PR.
Yes this is ideal. That would eliminate confusion and close the gap on any accidental or intentional modifications from underprivileged admins. |
Thanks for the feeback @danmooney2!
Thanks, I wasn't aware of this, good to know!
I do feel like that remark is very valid, and should certainly be supported. The biggest problem in my eyes currently, is the fact that on a clean installation of Magento, the directories The first fix which needs to happen here, is that those directories get created. I'm just not sure when they should get created? When setting up a new project, or when that media picker modal first tries to access a directory which doesn't exist yet? The second fix would then be to change the storage root to the directory which gets passed from javascript. Let me know your thoughts! |
I think it's OK to proceed with this PR. I wouldn't want dynamic folder creation based on client side values, and I (re-)noticed that a category image upon upload initially gets placed into a tmp folder inside catalog, and a) that's confusing UX to see that in media gallery b) if it gets chosen from the gallery inside tmp folder, then the file reference eventually becomes stale when it gets moved to its permanent residence. On top of that, file dispersion is enabled for products (i.e. p/o/p/popcorn.jpg ; overall not a desirable UX). Customizable storage root subpaths sound like a good idea at face value but there's too much baggage/overhead with the current inner workings of catalog media (like tmp storage) and there's legitimate concern of tampering with files contained within. Sure, the same file is going to be uploaded multiple times if the merchant wants to use the same category image they'd used prior, but it's the safer route. |
This PR has potential to break a lot of tests within Page Builder, even though we don't require bundled extensions to be ran for PRs I'd really appreciate if we could run Page Builder alongside the builds for this change. |
Hmm, I don't really like the state of this PR, I would not merge it as is currently. As already argued above, these directories which don't exist should get created somehow. For now I would just add the following lines to Magento\Cms\Helper\Wysiwyg\Images:: __construct: $this->_directory->create(\Magento\Cms\Model\Wysiwyg\Config::IMAGE_DIRECTORY);
$this->_directory->create(\Magento\Catalog\Model\ResourceModel\Category\Attribute\Frontend\Image::IMAGE_PATH_SEGMENT); // but then maybe without using the const and just using 'catalog/category', because this would introduce a dependency we don't want That would already solve the biggest problem for me. It's not the best solution, but might do for the interim, a more robust solution would need to be found later on which allows this to happen in a more automated fashion (maybe by defining directories in xml config files which should be created by default, this configuration could then be moved to the individual modules themselves instead of now doing this hardcoded in the cms module code and let the cms module code just find these configurations and create the directories if they don't exist?) |
@hostep we only utilize the |
@davemacaulay , @hostep we ran builds with proposed changes and a lot of tests related to PageBuilder is failing due to usage of wysiwyg folder |
Yes I'm aware that this PR is not good, I proposed a better change but haven't received much feedback on it yet. Should I just start a new PR with these suggested changes? |
Created a follow up PR which might be a better fix: #24878 |
Hi @vishal-7037, We have a fix #24878 for the same issue, but it does fix in backward compatible way, so by reviewing both solutions I decided to go with last one. I'm closing this PR. Thank you so much for your contribution! |
Hi @vishal-7037, thank you for your contribution! |
Description (*)
Set Media storage root directory to wysiwyg directory in pub/media folder.
Fixed Issues (if relevant)
Manual testing scenarios (*)
After Fixed:

Contribution checklist (*)