Image scaling not working if alt text is missing

의도된 동작인지 버그인지 확실하지 않지만, 최근(한 주쯤?) 업데이트 이후로 이미지에는 alt 텍스트가 없는데도 예전에는 작동하던 % 버튼(이미지 크기 조절용)과 실제 크기 조절 기능이 더 이상 작동하지 않습니다.

게시글에 여러 이미지가 있고 그중 하나에 alt 텍스트가 없다면, 해당 이미지의 % 버튼을 클릭하면 alt 텍스트가 있는 다른 이미지의 크기가 변경됩니다. (수정: alt 텍스트가 필요했다 해도 이런 일이 일어나서는 안 되므로 카테고리를 #contribute:bug로 변경했습니다)

다음은 작동하지 않지만, 예전에는 작동했습니다:
![690x184, 40%](upload://hash)

예상대로 이미지 크기 앞에 alt| 부분을 추가하면 문제가 해결됩니다.

이 문제를 적응시키기 위해 일부 토픽을 업데이트해야 하는데, 그렇지 않으면 나중에 다시 빌드될 때 이 이미지들이 100% 크기로 표시될 수 있습니다. 다른 분들도 같은 상황에 처할 수 있을 것 같아 이 게시글을 올립니다.

1개의 좋아요

Can repro, removing the alt text breaks image scaling.

2개의 좋아요

Hmm, what are your feelings on this one @sam?

1개의 좋아요

I do not think this ever worked without the alt text, I guess we could support it,

2개의 좋아요

It did work, I have several topics in my instance with the correct scaling and missing the alt text. If I rebake any of them the scaling is gone.

EDIT: Maybe related to this change?

I couldn’t find anything that would explain the difference on post cooking, though.

I don’t mind editing those topics, but others may also face this situation and the resize controls on the alt-less image shouldn’t change another image’s scale

Fair enough, if you are sure it worked previously I believe you 100%.

@david I guess this could have been your regression here, seems simple enough to fix?

4개의 좋아요

Yeah looks like this was my change. I had assumed the previous implementation was a bug. All our tests assume the dimensions will be after a | character:

I could revert us back to the old behaviour, and add a test to make sure it keeps working. But doing that means that you can never have an image with alt text like 123x123.

@renato do you know how you ended up without any pipe character in the markdown? As far as I know, all the UI options should generate it with a pipe :thinking:

6개의 좋아요

Yes, the posts where I noticed this behavior were all created using the API with a preset raw content that was tested before in the UI. I deliberately removed the alt texts of two images that wouldn’t make much sense in a screen reader.

I don’t mind adapting to the new behavior if that’s what you end up deciding.

Off-topic: may I ask for a plugin recommendation that changes [something] to some raw content as inspiration for a plugin of my own? This way I could do just another edit on all those topics and if I eventually need to change them again, a rebake would be enough.

2개의 좋아요

Yeah I think it is better to adapt to the new way here. We never really intended to support this. Wider support for more formats means more code in the backend and more testing.

Simplest would be to use db remap see: Replace a string in all posts - Self-Hosting - Discourse Meta

3개의 좋아요

OK, let me just keep the suggestion to only show the scale buttons on images that can be scaled.

Oh yes, for this specific change I can do this, thanks. Anyway, this isn’t the only place I’ve a preset raw content managed by an external service, maybe I could get some ideas from poll – or if you recall a simpler one, please let me know.

Thank you and sorry for so much noise for this small issue.

3개의 좋아요

Not at all, thanks for bringing this up and being so patient with us.

3개의 좋아요