From 5f0219160b8306a26619de5e0f2b43803b3e22c2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 24 Jul 2015 06:27:48 +0200 Subject: [PATCH] =?utf8?q?Don=E2=80=99t=20add=20a=20class=20=E2=80=9Cnull?= =?utf8?q?=E2=80=9D=20to=20an=20image=20if=20there=20is=20to=20be=20none?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../java/net/pterodactylus/sone/template/ImageLinkFilter.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/pterodactylus/sone/template/ImageLinkFilter.java b/src/main/java/net/pterodactylus/sone/template/ImageLinkFilter.java index 9ede851..458d40f 100644 --- a/src/main/java/net/pterodactylus/sone/template/ImageLinkFilter.java +++ b/src/main/java/net/pterodactylus/sone/template/ImageLinkFilter.java @@ -33,6 +33,7 @@ import net.pterodactylus.util.template.TemplateContext; import net.pterodactylus.util.template.TemplateContextFactory; import net.pterodactylus.util.template.TemplateParser; +import com.google.common.base.Function; import com.google.common.base.Optional; /** @@ -79,7 +80,12 @@ public class ImageLinkFilter implements Filter { if (image == null) { return null; } - String imageClass = valueOf(parameters.get("class")); + String imageClass = Optional.fromNullable(parameters.get("class")).transform(new Function() { + @Override + public String apply(Object input) { + return (input != null) ? input.toString() : null; + } + }).orNull(); int maxWidth = parseInt(valueOf(parameters.get("max-width")), MAX_VALUE); int maxHeight = parseInt(valueOf(parameters.get("max-height")), MAX_VALUE); String mode = valueOf(parameters.get("mode")); -- 2.7.4