XF 2.3 How to display an image in a XenForo Custom Field?

himmelman

Member
Hoping someone can help me out with a weird issue I'm having with custom fields. I'm trying to get images to display, but it's just not working for me, and I'm a bit stuck. It seems like the HTML isn't rendering the way I expect it to.

For instance, I have a custom field where people can paste an image URL, and I'm using <img src="{$value}" alt="{$title}" /> in the wrapper, but for some reason, the system is wrapping the URL in an <a> tag, which completely breaks the image. On top of that, I'd also like to make a field where users can pick an option from a list, and a specific banner image appears based on their choice. I'm trying to use conditional logic (if-else statements) in the wrapper for that, but I'm worried it's going to run into the same kind of rendering problem.

Basically, I can't seem to get a clean <img> tag to show up. Does anyone know what I might be doing wrong or have some tips on how to get this to work?
 
Is there a way to restrict the field to only allow images?
Maybe a clunky workaround but you can remove the other bbcode buttons with css

This works for me but you'd need to check your button ids as mine is slightly non-standard

Code:
.formRow--customField

{
    #xfSmilie-2,#textColor-2,#insertLink-2,#bold-2,#xfInsert-2,#paragraphFormat-2,#align-2,#xfList-2
    {
        display:none
       
    }
}
 
Text Input for URL
1755115981280.webp

Single Choice (Radio or Dropdown)
1755116091173.webp


Please note that it is not possible to use conditions or any other Xenforo template syntax elements for Value display HTML or Wrapper display HTML, it is only possible to use ... HTML :)

If you need smth. more sohisticated I'd take a look at Add-ons like
 
Last edited:
Back
Top Bottom