mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Make image resize controls more resilient (#8867)
Commit aa24be1 made it possible to build data attributes from image's
Markdown and this changes ensure that the resize controls still work
when data attributes are present.
This commit is contained in:
@@ -15,10 +15,15 @@ function buildToken(state, type, tag, klass, nesting) {
|
||||
|
||||
function wrapImage(tokens, index, state, imgNumber) {
|
||||
const imgToken = tokens[index];
|
||||
let selectedScale = imgToken.content
|
||||
.split(",")
|
||||
.pop()
|
||||
.trim();
|
||||
const sizePart = imgToken.content
|
||||
.split("|")
|
||||
.find(x => x.match(/\d{1,4}x\d{1,4}(,\s*\d{1,3}%)?/));
|
||||
let selectedScale =
|
||||
sizePart &&
|
||||
sizePart
|
||||
.split(",")
|
||||
.pop()
|
||||
.trim();
|
||||
tokens.splice(
|
||||
index,
|
||||
0,
|
||||
|
||||
Reference in New Issue
Block a user