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

Add alt_text field to image content type #701

Merged
merged 20 commits into from
Oct 21, 2024
Merged

Conversation

jackahl
Copy link
Member

@jackahl jackahl commented Sep 25, 2024

This PR is for issue #700. Most of the code is taken from #518, as it was easier to copy out the relevant code than to fix the merge conflicts.

The related issue in volto is plone/volto#6302

@mister-roboto
Copy link

@jackahl thanks for creating this Pull Request and helping to improve Plone!

TL;DR: Finish pushing changes, pass all other checks, then paste a comment:

@jenkins-plone-org please run jobs

To ensure that these changes do not break other parts of Plone, the Plone test suite matrix needs to pass, but it takes 30-60 min. Other CI checks are usually much faster and the Plone Jenkins resources are limited, so when done pushing changes and all other checks pass either start all Jenkins PR jobs yourself, or simply add the comment above in this PR to start all the jobs automatically.

Happy hacking!

Copy link
Member

@davisagli davisagli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple minor comments, but basically looks good to me.

plone/app/contenttypes/schema/image.xml Outdated Show resolved Hide resolved
plone/app/contenttypes/schema/image.xml Show resolved Hide resolved
@davisagli
Copy link
Member

Uh, there are failing tests though

@jensens
Copy link
Member

jensens commented Sep 26, 2024

I like this long needed addition - but: this needs more work to get it into all places where tags are generated, esp this are the scales. Merging this without consistent output also in Classic UI does not help.

@jackahl
Copy link
Member Author

jackahl commented Sep 26, 2024

Uh, there are failing tests though

trying to fix them, but I am very unfamiliar with Classic Plone templates (I think those should be the cause for the test failures), would appreciate some help from someone at the @plone/classicui-team here then

@jackahl
Copy link
Member Author

jackahl commented Sep 26, 2024

I like this long needed addition - but: this needs more work to get it into all places where tags are generated, esp this are the scales. Merging this without consistent output also in Classic UI does not help.

Agreed. Though I'd say this should be better done and evaluated by the classic UI team. Would someone at the @plone/classicui-team be willing to champion this effort?

@petschki
Copy link
Member

petschki commented Sep 26, 2024

Since most of the images are created with the @@images view this needs to be implemented here too https://github.com/plone/plone.namedfile/blob/master/plone/namedfile/scaling.py#L158

Another place is the resolve_uid_and_caption transform which also tries to set the alt parameter, but I could not quickly find where its defined.

And there are maybe some more places wich have to be updated ... pandoras box has opened 😉

@MrTango
Copy link
Contributor

MrTango commented Sep 26, 2024

resolve_uid_and_caption

used to do it, but this is wrong, as images inside of TinyMCE should get the correct ALT text by the Editor.
This generated ALT text should only be used in listings, not everywhere where images are used. Only the Editor can know if an ALT text is needed and what it has to contain. Sometime an empty one is what you need.

@yurj
Copy link
Contributor

yurj commented Sep 27, 2024

The value of alt_text should be the default of the input when adding the image. Then the editor can choose to keep it or change or remove it. Win win, very few changes all backward compatible.

Also @davisagli suggested to implement it as a behaviour, so this would happen only when the behaviour is applied.

@jackahl
Copy link
Member Author

jackahl commented Sep 27, 2024

The value of alt_text should be the default of the input when adding the image. Then the editor can choose to keep it or change or remove it. Win win, very few changes all backward compatible.

Also @davisagli suggested to implement it as a behaviour, so this would happen only when the behaviour is applied.

@yurj seems like a decent idea as well. I am quite agnostic about whats the best solution. But I think gathering some more opinions might help, coming to a decision.

@jackahl
Copy link
Member Author

jackahl commented Oct 1, 2024

@plone/classicui-team cold one of you maybe take care of fixing the listing templates properly. I tried my best for quite while but 0a3fb93 was the best I could do with my limited knowledge of the templating syntax. But that broke all tests, where no alt tag was provided :/

@yurj
Copy link
Contributor

yurj commented Oct 1, 2024

item is a contentlisting and does not have an alt_image attribute, I suppose, until you add it to the catalog as metadata.

@jackahl
Copy link
Member Author

jackahl commented Oct 1, 2024

item is a contentlisting and does not have an alt_image attribute, I suppose, until you add it to the catalog as metadata.

@yurj from what I could test by just checking the alt tag in my local build it did show up in the listing

@yurj
Copy link
Contributor

yurj commented Oct 1, 2024

item is a contentlisting and does not have an alt_image attribute, I suppose, until you add it to the catalog as metadata.

@yurj from what I could test by just checking the alt tag in my local build it did show up in the listing

you're right. contentlisting do a getObject if there's no metadata. but from Jenkins I can see:

File "/home/runner/work/plone.app.contenttypes/plone.app.contenttypes/.tox/test/lib/python3.11/site-packages/plone/app/contentlisting/catalog.py", line 52, in __getattr__
    raise AttributeError(name)
AttributeError: alt_text

here:
https://github.com/plone/plone.app.contentlisting/blob/abbeb13d7e2550c148aead3645d02e4514cbb828/plone/app/contentlisting/catalog.py#L39C1-L52C35

Maybe you miss some upgrade step here?

e5004cf

you add the field but you need to run the types upgrade step to get the change in the types.xml file.

@jackahl
Copy link
Member Author

jackahl commented Oct 2, 2024

@mauritsvanrees I did how you advised and there are now at least fewer tests failing. Though I dont get why those are failing at all as they should be unrelated. I was also not able to provoke any errors on the local build anymore.

@jackahl
Copy link
Member Author

jackahl commented Oct 2, 2024

EDIT: I think I finally fixed it

I was able to reproduce and fix few more error by locally replicating the robot test setup. But there are still 4 robot tests failing. I just can't reproduce them locally. Test feedback is also very lacking with:

AssertionError: Element 'id=content' should have contained text 'Test Document' but its text was 'We’re sorry, but there seems to be an error…
If you are certain you have the correct web address but are encountering an error, please contact the site administration.'.

Any ideas on how to reproduce, inspect or even fix this?

@jackahl
Copy link
Member Author

jackahl commented Oct 2, 2024

@jenkins-plone-org please run jobs

1 similar comment
@jackahl
Copy link
Member Author

jackahl commented Oct 4, 2024

@jenkins-plone-org please run jobs

@jackahl
Copy link
Member Author

jackahl commented Oct 4, 2024

So locally all test pass now. Annoyingly there are still some test failures on Jenkins. My guess would be that those are flaky? Locally I cannot run those, as I have an error building buildout.coredev

@jackahl
Copy link
Member Author

jackahl commented Oct 11, 2024

Lets try another @jenkins-plone-org please run jobs to make sure they are not flaky

@jackahl
Copy link
Member Author

jackahl commented Oct 15, 2024

@plone/classicui-team could one of you maybe give fixing the remaining tests a try. For me they pass locally. So cannot really reproduce the CI test failures

@petschki
Copy link
Member

Those flaky robottests should get fixed by plone/Products.CMFPlone#4019 but Jenkins currently has problems setting up robotframework browser ... and there's a fix for the latest py3.12 here plone/Products.CMFPlone#4023 ... all in all I'd say if the tests pass on 6.1-py3.10 I'd merge it.

The git diff shows this as a move of the image field above the alt_text field, which boils down to the same thing. ;-)
@mauritsvanrees
Copy link
Member

@jenkins-plone-org please run jobs

Copy link
Member

@mauritsvanrees mauritsvanrees left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

We should make more changes in other packages, like probably plone.outputfilters or maybe integration in the image plugin in TinyMCE. But this is the basis for making that possible. So let's merge.

One test failure on one of the Jenkins jobs, but it is unrelated.

@mauritsvanrees mauritsvanrees merged commit 6230bd4 into master Oct 21, 2024
11 of 12 checks passed
@mauritsvanrees mauritsvanrees deleted the add-image-alt-tag branch October 21, 2024 16:27
@mauritsvanrees
Copy link
Member

Merged. Thanks @jackahl !

@davisagli
Copy link
Member

@mauritsvanrees Hang on, I was assuming this change will target Plone 6.2 or later. It is pretty late to add this new feature to 6.1, and more work is needed to use the new field everywhere, especially in Volto.

@davisagli
Copy link
Member

@mauritsvanrees I especially object to adding the new field directly to the image content type schema in Plone 6.1, because it makes it quite difficult to remove it in projects that already have a custom alt text field. It should be a behavior so it can be added in a more controlled way.

@mauritsvanrees
Copy link
Member

I may have been too trigger happy, trying to get some open stuff merged before it lingers too long.
Let me see if I can undo something.

@mauritsvanrees
Copy link
Member

I have undone the change.

@davisagli
Copy link
Member

@mauritsvanrees Thanks. I do want to come back to this one, I just think it needs a bit more work to make sure we can roll it out smoothly to existing sites.

mauritsvanrees added a commit that referenced this pull request Oct 21, 2024
This reverts commit e37ec9a.

So this restores the status from before #701 (comment)
mauritsvanrees added a commit that referenced this pull request Oct 21, 2024
This reverts commit e37ec9a.

So this restores the status from before #701 (comment)
The original code changes in here are mostly from @jackahl.
@mauritsvanrees
Copy link
Member

I have created a new PR as starting point, with the same code as was in here:
#705

@davisagli Thanks for keeping an eye out for what gets into core! :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants