[ticket/16977] Fix cron-job img tag layout and accessibility#6376
Conversation
Do you have some reference (link) to those styles?
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Img |
ProLight is one of them. But the issue is with core, not the style — invisible elements should never affect layout.
Yes, setting the
|
|
The problem is where the image is HTML attributes (if empty) can not be in the core. Like |
|
I think this was a hack to run the cron jobs asynchronously so it doesn't interfere with page load. |
In that case, the style rules for core are directly violating W3C WAI accessibility criteria in this specific case. Or do you mean the HTML should be |
Yeah, that's what I figured. Don't see why that wouldn't do the trick, other than that |
What if someone disabled JS? |
It should do, I'll leave the answer to the Devs though. |
Upon testing, the worst case scenario here is that the cron job doesn't run on that specific page load; it'll still run the next time a user not using IE or disabling JS visits. In other words, the worst case is as if (for the purpose of the cron job) that individual site visit hadn't taken place. Is this a worthwhile tradeoff for the reduced hackiness? My gut says yes, but I'd like to get others' thoughts. There's also the option of |
|
Not true our guidelines have been updated https://area51.phpbb.com/docs/dev/master/development/html/guidance.html No slashes and " are required. We follow idiomatic standards for html. We also no longer support IE so not sure thats an issue. As 3di pointed out all html should be avoided in core. Wether the cron not always running is acceptable, I will let others weigh in on. But my vote is on a js solution. |
|
@hanakin this is a special case. That cron should always be running (ready to). And JS is not an acceptable solution, IMHO. And I pointed out that INLINE STYLING should be avoided in core in this case, please read the proposed code, there are not so many ways to do what you want if not re-factor the whole stuff. But since this is a PR against |
|
Yup agree with @3D-I on this.
Yup agree with @3D-I on this. Please pursue a non JS solution. |
|
OK, next question: I agree in principle that all HTML should be kept in templates, so an ideal solution would look something like this*:
$template->assign_var('CRON_TASK_URL', $url);
{% if not S_IS_BOT %}
{#
Runs the cron task by triggering server request to the URL on load.
`img` is preferred over JS to ensure maximum compatibility.
`sr-only` hides visually, `aria-hidden` hides from screen-readers;
`hidden` or `display: none` would prevent the task from running.
#}
<img src="{CRON_TASK_URL|e('html_attr')}" alt="" width="1" height="1" class="sr-only" aria-hidden="true">
{% endif %}However, this would leave This seems like a much more far-reaching consequence than the lack of support for IE or people turning off JS, both of which are tiny demographics. That leaves 3 alternatives that I can think of:
My vote goes to #3, as it seems the most "correct" while also being robust. Thoughts? * I kept |
|
Just a note (again) the alt text is also displayed on the page if the image can't be loaded for some reason: for example, network errors, content blocking, or linkrot. |
You've mentioned this before, but I'm not sure what its significance is? The tag is styled invisibly, so it won't be visible either way; setting In no case should an |
|
It is very known that you can see the word "cron" in case of issues. The tag is not styled invisibly, the IMG is 1px X 1px which makes it invisible to the human eye. |
Displaying the text "cron" via
If we want to add user-visible error reporting, the proper way would be via I'd humbly suggest that the question of error handling stays out of scope for this particular PR, which relates to styling and accessibility. Perhaps someone else can create another PR for the logging issue if that isn't already handled satisfactorily. |
|
Agreed. The |
|
The display of the raw text of the ALT attribute is perfectly fine in those situations as per That's it by design btw, IMHO. In this special case. If it appears it means your style is badly coded or your board is not fully functional, that's it. |
Perfect example of why to leave it blank. From that page:
If you're using a text reader and it reads "cron" as part of the page it would be very weird. If it's left blank it would not adversely affect anything so there should be no reason to not make the change. |
|
So, let's go to the origin of it and blame it. Let's see what the devs will say. |
This is patently false. It can be left blank. I'll quote from the link you provided:
|
|
That's not a part of the guidelines though, I recall also extensions being denied for such a "mistake". |
|
In the rare event that there is something in the phpBB style rules or conventions that directly contradicts W3C's Web Content Accessibility Guidelines, I'd suggest that it'll generally be phpBB that needs to change and not the WCAG... phpBB's great and all, but it's not as authoritative as the standards organization for the web itself 😉 |
There is a front-end developer team leader in charge, on the graphs. 😶 |
|
Changes made based on what I outlined in option #3 of #6376 (comment) |
|
@lionel-rowe I love your last commit. 💯 I have no time to review it now, I saw something though that can be improved, anyway... I will post here my thoughts maybe tonight or tomorrow. |
adde061 to
5065ccc
Compare
5065ccc to
efdcaba
Compare
5c09dc7 to
c8d8d66
Compare
[ticket/16977] Fix cron-job img tag layout and accessibility
|
Just checked myself and it seems like tests will still need to be updated. |
|
@lionel-rowe Your commits need to have this format: You can do it like this or if you want i can update it for you |
c8d8d66 to
b92b695
Compare
|
Tests and commit messages should now be fixed. |
b92b695 to
e53102f
Compare
PHPBB3-16977
[ticket/16977] Fix cron-job img tag layout and accessibility
[ticket/16977] Fix cron-job img tag layout and accessibility
|
I've created a master version of your PR that will ease merging the PR: #6381 |
The cron-job image, as set in
viewforum.phpandcontroller/helper.php:Renders like this:
2 issues:
positionis not set, defaulting tostatic, therefore still affects layout (breaks some styles)altis set to"cron", when it should be"";altattribute is supposed to be an accessible alternative representation to the user agent, so should be set to empty string if the element is not supposed to be visibleChecklist:
Tracker ticket (set the ticket ID to your ticket ID):
https://tracker.phpbb.com/browse/PHPBB3-16977