Skip to content
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

[5.2] Add text context info for post request for dragging image in editor in article #39958

Open
wants to merge 4 commits into
base: 5.2-dev
Choose a base branch
from

Conversation

korenevskiy
Copy link
Contributor

When dragging an image in the article editor, a POST request is sent. I added a context with information about the article ID to this POST request. This will allow on the server side to give names to pictures with the content of the article ID. In general, it is useful for the component to know which article this picture belongs to.

Before POST/GET request

option: com_media
format: json
url: 1
task: api.files
path: local-images:

content: "imageData"
name: "____Image.jpg"
parent: "publicacations_2023"

After Fix POST/GET request

option: com_media
format: json
url: 1
task: api.files
path: local-images:

content: "imageData"
name: "____Image.jpg"
parent: "publicacations_2023"

context: "com_content.article:23"

This context will allow you to dynamically manage the saved files when inserting them into the article editor.

  1. Manage the directory depending on which directory the article is saved in. For example, it allows you to automatically store news image files separately in the news directory and separately image files of products and goods separately from each other.
  2. Allows you to set the article ID or module ID in the file name. That will allow you to know the ownership of the image.

And how to find out the ownership and refactoring of a folder of pictures if it's just a bunch of sketched different files.
A specialist site manager in the modern world does not have to worry about the file name, the file should automatically be named itself and saved in the right directory. The site manager should only think about the description of the photo.

This PR does not provide new features. But it gives an additional line of information for plugins and components to implement broad functionality. If even now it will seem superfluous. Then in the near future, administrators will be able to at least download a plugin to manage the location of images. Now every social network uploads images simply. The user has nothing to do with the location of the images on the social network server. We have to take the same step in Joomla

I wanted to add this PR together with #39957 please support this PR

@dgrammatiko
Copy link
Contributor

This is not needed at all. For all stages of the model there are corresponding events that actually have the context you are passing here but most importantly in order to tweak the core functionality you are forced to use a plugin thus the whole context idea here is useless. Please check the events here: #28886
and maybe https://github.com/ttc-freebies/plugin-responsive-images/tree/4.0.0/src/plugins/media-action/responsive as a proof of what you're introducing could be done already and it doesn't need the info to be passed in the post request.

@korenevskiy
Copy link
Contributor Author

korenevskiy commented Feb 27, 2023

This is not needed at all. For all stages of the model there are corresponding events that actually have the context you are passing here but most importantly in order to tweak the core functionality you are forced to use a plugin thus the whole context idea here is useless. Please check the events here: #28886 and maybe https://github.com/ttc-freebies/plugin-responsive-images/tree/4.0.0/src/plugins/media-action/responsive as a proof of what you're introducing could be done already and it doesn't need the info to be passed in the post request.

  • Tell me how you can automatically manage the location of the image file in the desired directory?
  • Tell me how to find out the ID of the material to add it to the image file name?

@dgrammatiko
Copy link
Contributor

Tell me how you can manage the location of the desired directory automatically?

I was doing that for over a decade and the process is the same although some things have changed in the j4 API: https://github.com/dgrammatiko/imageUploaderHelper

Tell me how to find out the ID of the material to add it to the image file name?

There are many ways to go, the easiest probably is to pass the needed data to the session so the plugin, when it executes, could reuse it. An example could be https://github.com/dgrammatiko/sloth-pkg/blob/8dbe65b679af8ad60c9f9ac36ee54b754300b17f/plg_sampledata/sloth.php#L179

There are other ways though.

@richard67
Copy link
Member

@korenevskiy Besides the above discussion: Can it be that you wanted to make this PR for the 4.3-dev branch but then by mistake have made it for the 4.2-dev branch? The PR shows 2044 changed files.

@korenevskiy
Copy link
Contributor Author

korenevskiy commented Feb 27, 2023

Besides the above discussion: Can it be that you wanted to make this PR for the 4.3-dev branch but then by mistake have made it for the 4.2-dev branch? The PR shows 2044 changed files.

Yes, you are completely right. I did PR for 4.3 dev, but after publishing the PR, for some reason unknown to me, he ended up in the 4.2 branch. I did PR on the site, without using code editors.

@dgrammatiko
Copy link
Contributor

@laoneo any thoughts here?

@richard67
Copy link
Member

Yes, you are completely right. I did PR for 4.3 dev, but after publishing the PR, for some reason unknown to me, he ended up in the 4.2 branch.

@korenevskiy You can change the base branch to 4.3-dev by using the "Edit" button right beside the title of this PR on GitHub. After that you can change the base branch from 4.2-dev to 4.3-dev. Let me know if I shall help with doing that.

@korenevskiy korenevskiy changed the base branch from 4.2-dev to 4.3-dev February 27, 2023 20:37
@korenevskiy
Copy link
Contributor Author

korenevskiy commented Feb 27, 2023

You can change the base branch to 4.3-dev by using the "Edit" button right beside the title of this PR on GitHub. After that you can change the base branch from 4.2-dev to 4.3-dev. Let me know if I shall help with doing that.

Thank you, if I had known earlier, I wouldn't have created a lot of bad PR here. 👍👍

@joomla-cms-bot joomla-cms-bot added NPM Resource Changed This Pull Request can't be tested by Patchtester PR-4.3-dev and removed Unit/System Tests labels Feb 27, 2023
…gin.es5.js

Co-authored-by: Dimitris Grammatikogiannis <dg@dgrammatiko.dev>
@korenevskiy
Copy link
Contributor Author

There are many ways to go, the easiest probably is to pass the needed data to the session so the plugin,

It looks like we will never get a tool for automatic image management. Plugins are originally designed to work with contextual data. Working with the session is not the task of the plugin, but the task of the kernel. This context is transmitted only by the plugin for which it is intended. In fact, plugins are blind when processing images. This is important information. Very important.

@dgrammatiko
Copy link
Contributor

Working with the session is not the task of the plugin, but the task of the kernel.

Then make a proposal for those changes to be applied GLOBALLY. Adding sporadically different context, etc is making the system very unpredictable for devs.

To be clear here, I'm not against adding more data, it's that this is not standardised, ie this event will be available only for tinyMCE drag and drop images, but not for any other editor and neither for tinyMCE if you upload a file using the media manager modal. Consistency is key...

@korenevskiy
Copy link
Contributor Author

korenevskiy commented Feb 27, 2023

@dgrammatiko

  1. I agree. The behavior should be predictable. And it is necessary to define a general rule for the context of all dragged images. Let's think about standardization.
  2. There is no need to consider other code editors here. Since this script only applies to TinyMCE. This means that other code Editors invent this context for themselves. And they will invent until there is no standard.
  3. This context in this PR is not passed to the plugin as a parameter. This context will be located simply in the Input object. Which does not impose new rules. But it is only an option.
  4. Later I will think about adding a context for uploading a file through a modal window. Of course, if everyone supports this PR.

@dgrammatiko
Copy link
Contributor

Later I will think about adding a context for uploading a file through a modal window. Of course, if everyone supports this PR.

If you manage to cover the modal as well I'm positive on this. Also you need to add the missing code in the media manager that will pass the input data to the events on each adapter (which right now is missing and quite frankly the extra data is useless as is)

@korenevskiy
Copy link
Contributor Author

If you manage to cover the modal as well I'm positive on this. Also you need to add the missing code in the media manager that will pass the input data to the events on each adapter (which right now is missing and quite frankly the extra data is useless as is)

In the case of a Media Manager, context is useless and unnecessary. Since the Media Manager does not carry information about the Article and Category. I.e., there is nothing to transmit in the context in the Media Manager.
Tell us about your vision of what the context should look like for it to be useful?

@Hackwar Hackwar added the Feature label Apr 7, 2023
@HLeithner HLeithner changed the base branch from 4.3-dev to 5.0-dev May 8, 2023 15:02
@HLeithner
Copy link
Member

This pull request has been automatically rebased to 5.0-dev. No new features will be merged into Joomla! 4.3 series. Joomla! 4.4 series is a bridge release to make migration from Joomla! 4 to 5 as smooth as possible.

@HLeithner HLeithner changed the base branch from 5.0-dev to 5.1-dev September 30, 2023 22:50
@HLeithner
Copy link
Member

This pull request has been automatically rebased to 5.1-dev.

@HLeithner HLeithner changed the base branch from 5.1-dev to 5.2-dev April 24, 2024 09:08
@HLeithner
Copy link
Member

This pull request has been automatically rebased to 5.2-dev.

@HLeithner HLeithner changed the title Add text context info for post request for dragging image in editor in article [5.2] Add text context info for post request for dragging image in editor in article Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature NPM Resource Changed This Pull Request can't be tested by Patchtester PR-5.0-dev PR-5.2-dev
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants