From: David ‘Bombe’ Roden Date: Fri, 24 Jul 2015 04:27:48 +0000 (+0200) Subject: Don’t add a class “null” to an image if there is to be none X-Git-Tag: 0.9.4^2~13 X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=commitdiff_plain;h=5f0219160b8306a26619de5e0f2b43803b3e22c2 Don’t add a class “null” to an image if there is to be none --- 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"));