Opened 16 months ago
Closed 16 months ago
#63731 closed defect (bug) (wontfix)
wp-emoji-release.min.js Requires URL Update
| Reported by: | isaumya | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Emoji | Version: | |
| Severity: | normal | Keywords: | has-patch |
| Cc: | Focuses: | javascript |
Description (last modified by )
Currently /wp-includes/js/wp-emoji-release.min.js loads the emojis inside an img tag like this: <img draggable="false" role="img" class="emoji" alt="🚀" src="https://cdn.jsdelivr.net/gh/jdecked/twemoji@16.0.1/assets/1f680.svg">
But unfortunately, the URL that it is using is no longer valid and 404. So, instead of doming cdn.jsdelivr.net/gh/jdecked/twemoji@16.0.1/assets/<EMOJI>.svg the path needs to be updated to /assets/svg/<EMOJI>.svg.
So, for example, here are some emoji URL that wp-emoji-release.min.js will try to load and all of them are 404:
https://cdn.jsdelivr.net/gh/jdecked/twemoji@16.0.1/assets/1f680.svghttps://cdn.jsdelivr.net/gh/jdecked/twemoji@16.0.1/assets/2139.svg
But instead, if you try:
https://cdn.jsdelivr.net/gh/jdecked/twemoji@16.0.1/assets/svg/1f680.svghttps://cdn.jsdelivr.net/gh/jdecked/twemoji@16.0.1/assets/svg/2139.svg
You will see them working.
Attachments (4)
Change History (22)
#3
@
16 months ago
You are absolutely right @Presskopp. Also, yes @abcd95 that's the line that needs patching. Simply need to add /svg/ at the end of the base path.
#5
@
16 months ago
As /wp-includes/js/wp-emoji-release.min.js is auto generated from wp-includes/js/twemoji.min.js
/*! This file is auto-generated */ // Source: wp-includes/js/twemoji.min.js
#6
@
16 months ago
- Description modified (diff)
I think your site might use the emoji_svg_url hook, and that would need to include the svg directory for the jsDelivr CDN.
add_filter(
'emoji_svg_url',
function() {
return 'https://cdn.jsdelivr.net/gh/jdecked/twemoji@16.0.1/assets/svg/';
}
);
The default SVG URL uses s.w.org, resulting in images like
<img draggable="false" role="img" class="emoji" alt="🚀" src="https://s.w.org/images/core/emoji/16.0.1/svg/1f680.svg">
The twemoji script defaults refer to PNG assets, which the settings override for SVG.
#7
@
16 months ago
Hi @sabernhardt,
Though the site itself is overwriting emoji_svg_url filter but most optimization plugins like Perfmatters, WP Rocket etc. adds this:
add_filter( 'emoji_svg_url', '__return_false' );
Which disables the loading of emojies over s.w.org and instead using the jsdelivr.net system. The problem is with the base URL of cdn.jsdelivr.net system which needs to add /svg/ at the end of the base path.
That's the goal of this trac ticket. To get that jsdelivr base URL fixed inside twemoji.js.
The twemoji script defaults refer to PNG assets
True. But if you look at https://cdn.jsdelivr.net/gh/jdecked/twemoji@16.0.1/assets/ you will see that even for the png assets you need to go inside /72x72/ path now.
But, whether the wp core team like to stick with png then the /72x72/ needs to be appended to the jsdelivr URL or if wants to use SVG then /svg/ - in either way the base URL needs to be updated.
#8
@
16 months ago
- Focuses ui removed
- Milestone Awaiting Review
- Resolution → wontfix
- Severity major → normal
- Status new → closed
As mentioned above, by default WordPress serves images from s.w.org and the base setting in the twemoji script is ignored.
Testing with add_filter( 'emoji_svg_url', '__return_false' ); removes the full URL and sets the image source to src="1f426-200d-1f525.svg", so patching the base url in the JavaScript file will make no difference for that use case.
As the code is working without any plugins enabled, I don't think there's any value in further patching the version of twemoji included in WordPress Core as it's the responsibility of plugins modifying the code to ensure they do so in a bug free manner.
Furthermore, I think attempting to defend against plugin bugs will introduce problems as valid urls could be in a wide range of formats.
#9
follow-up:
↓ 18
@
16 months ago
- Resolution wontfix
- Status closed → reopened
Hi @peterwilsoncc, I'm sorry but I do not agree with you. As per my understanding (corrent me if I am wrong), WP Core gives users both options:
- Load the emojis via
s.w.org(Default) - Load the emojis via
cdn.jsdelivr.net(Fallback in case any user does not want to use thes.w.org)
Regardless of plugins, as a WP user anyone can choose to not use s.w.org in which case the fallback URL gets active.
The problem is that the fallback URL path is not proper and is causing 404. I understand that the issue is not present when using the default s.w.org but that does not mean that the issue with the fallback URL (which is part of WP core) should not be fixed.
#10
@
16 months ago
- Resolution → wontfix
- Status reopened → closed
@isaumya You're seemingly wrong, see:
Oh, yes, this has been mentioned before, but still, there is no fallback in core
#11
@
16 months ago
So, you are saying that the wrong base URL that's setup here: https://github.com/WordPress/wordpress-develop/blob/6.8.2/src/js/_enqueues/vendor/twemoji.js#L26-L34 will remain wrong? I mean in case add_filter( 'emoji_svg_url', '__return_false' ); is used then the default base from twemoji.js kicks in which is where the problem lies and you are saying that as twemoji.js is an external library, it won't be fixed. Right?
#12
@
16 months ago
- Resolution wontfix
- Status closed → reopened
Uh, I'm sorry. I tested it again using
add_action( 'after_setup_theme', function() {
add_filter( 'emoji_svg_url', '__return_false' );
});
You're right - you'll get a connection failed.
#13
follow-up:
↓ 16
@
16 months ago
This should be reported upstream then ..
This ticket was mentioned in PR #9303 on WordPress/wordpress-develop by @Presskopp.
16 months ago
#14
- Keywords has-patch added
#15
@
16 months ago
I totally messed up the patch on github somehow. Please see https://github.com/Presskopp/wordpress-develop/blob/patch-13/src/js/_enqueues/vendor/twemoji.js for the correct version
#16
in reply to: ↑ 13
;
follow-up:
↓ 17
@
16 months ago
Replying to Presskopp:
This should be reported upstream then ..
Well, no, it's not an issue in the upstream version. The upstream version works fine with the default cdn.jsdelivr.net URL. WordPress uses a customized version of twemoji - because it has been customized, the original default cdn.jsdelivr.net URL no longer works. This is not really a problem, since WordPress does not use that CDN anyway but instead uses its own s.w.org URL for serving assets.
If you really want to use the cdn.jsdelivr.net CDN, you could just do this:
add_filter(
'emoji_svg_url',
function () {
return 'https://cdn.jsdelivr.net/gh/jdecked/twemoji@16.0.1/assets/svg/';
}
);
#17
in reply to: ↑ 16
@
16 months ago
Replying to siliconforks:
You are right. I was under the impression the base path was missing the size, but obviously it gets appended later.
#18
in reply to: ↑ 9
@
16 months ago
- Resolution → wontfix
- Status reopened → closed
Replying to isaumya:
Hi @peterwilsoncc, I'm sorry but I do not agree with you. As per my understanding (corrent me if I am wrong), WP Core gives users both options:
- Load the emojis via
s.w.org(Default)- Load the emojis via
cdn.jsdelivr.net(Fallback in case any user does not want to use thes.w.org)Regardless of plugins, as a WP user anyone can choose to not use
s.w.orgin which case the fallback URL gets active.
I'm sorry, but it is indeed a misunderstanding.
WordPress does not provide an option for users to choose the fallback URL. WordPress will always use s.w.org.
WordPress does provide filters to allow developers to filter the URLs, using the filters emoji_url and emoji_svg_url. However, these filters must:
a) return a string
b) return the fill path to the PNG file and SVG files respectively.
You can see an example of the correct use of these filters in a plugin I maintain.
The code example provided by @siliconforks in the comment above is the correct way to use cdn.jsdelivr.net, as seen in this code example.
If a plugin developer doesn't follow these requirements, then yes, the emoji images will produce a 404 error and there is nothing WordPress can do about it. Returning false on these filters is incorrect.
I am going to reclose this ticket as wontfix for the reason stated earlier: attempting to defend against plugins introducing bugs to this code will lead to more problems than it will solve.
Discussion can continue on closed tickets.
The base URL is set in
\wp-includes\js\twemoji.jsin Line 27:This one should be patched.