PsiElementVisitor (final @NotNull ProblemsHolder holder, boolean isOnTheFly) { return new XmlElementVisitor() { @Override public void visitXmlAttribute(@NotNull XmlAttribute attribute) { XmlTag parent = attribute.getParent(); if (!(parent instanceof HtmlTag) || XmlHighlightVisitor.isInjectedWithoutValidation(parent)) { return; } String name = attribute.getName(); if (HtmlReferenceProvider.SizeReference.HEIGHT_ATTR_NAME.equalsIgnoreCase(name) || HtmlReferenceProvider.SizeReference.WIDTH_ATTR_NAME.equalsIgnoreCase(name)) { final XmlAttributeValue value = attribute.getValueElement(); if (value != null && value.getTextLength() > 0) { final PsiReference[] refs = value.getReferences(); final boolean isHeight = HtmlReferenceProvider.SizeReference.HEIGHT_ATTR_NAME.equalsIgnoreCase(name); if (refs.length == 1 && refs[0] instanceof HtmlReferenceProvider.SizeReference sizeReference && refs[0].getRangeInElement().getLength() >= 2 // avoid errors on concatenations ) { PsiElement element = sizeReference.resolve(); if (element == null) { final ImageInfoReader.Info imageInfo = sizeReference.getImageInfo(); if (imageInfo == null || imageInfo.height == 0 || imageInfo.width == 0 || imageInfo.isSvg()) { return; } final String adequateValue = String.valueOf(isHeight ? imageInfo.height : imageInfo.width); final String message = HtmlToolsBundle.message( isHeight ? "html.inspections.check.image.height.fix.message" : "html.inspections.check.image.width.fix.message", adequateValue); final MyFix fix = new MyFix(message, HtmlToolsBundle.message("html.inspections.check.image.fix.family"), adequateValue); holder.registerProblem(value, HtmlToolsBundle.message( isHeight ? "html.inspections.check.image.height.message" : "html.inspections.check.image.width.message", adequateValue), fix); } } } } } }; }