Lack of interest Ability to change attachment button icon/label

This suggestion has been closed automatically because it did not receive enough votes over an extended period of time. If you wish to see this, please search for an open suggestion and, if you don't find any, post a new one.

digitalpoint

Well-known member
It would be nice if we could change the default attachment icon and text when using the upload_block macro. As it stands, you need to replicate upload_block, upload_link and upload_link_from_data macros just to change the icon attribute on the button and add a button attribute (which will be used as the text).

Not everything as generic as "Attach files". In my use case, a user is only allowed to upload images, so wording it "Upload images" instead of "Attach files" causes less confusion for end-users (they also aren't really "attachments" for what I'm using them for). I've done it by replicating the macros, but it would be nice if we could pass button and icon selection in with $attachmentData (the constraints).

Just an idea...

1586238613148.webp
 
Upvote 4
This suggestion has been closed. Votes are no longer accepted.
I know this is old, but I constantly run into this issue. I ended up making a single template modification for the helper_attach_upload that maintains backward compatibility, and also lets you (optionally) override button text, icon and fa (FontAwesome icon). It's backwardly compatible (leveraging the ability for XenForo macros to have default values for variables), so it doesn't break anything.

Template: helper_attach_upload

Search type: Regular expression

Find:
Code:
#(arg-hiddenName="attachment_hash")(.*?<xf:button.*?icon=").*?(".*?)/>(.*?arg-hiddenName="attachment_hash")(.*?arg-hiddenName=".*?")(.*?name="upload_block".*?arg-hiddenName=".*?")(.*?arg-hiddenName=".*?")#si

Replace:
Code:
$1
arg-buttonText="{{ phrase('button.attach') }}" arg-icon="attach" arg-fa=""$2{$icon}" fa="{$fa}$3>{$buttonText}</xf:button>$4 arg-buttonText="{{ phrase('button.attach') }}" arg-icon="attach" arg-fa=""$5
arg-buttonText="{$buttonText}" arg-icon="{$icon}" arg-fa="{$fa}"$6 arg-buttonText="{{ phrase('button.attach') }}" arg-icon="attach" arg-fa=""$7
arg-buttonText="{$buttonText}" arg-icon="{$icon}" arg-fa="{$fa}"

You can then use the normal upload_block macro (the example is the code for the first button in the screenshot below):
Code:
<xf:macro template="helper_attach_upload" name="upload_block" arg-attachmentData="{$attachmentDataFront}" arg-buttonText="{{ phrase('button.upload_id_front') }}" arg-icon="" arg-fa="fa-id-card" />

This allows you to do things like this (this is an identity verification addon I have... obviously the IDs are samples):

1675787526270.webp
 
Top Bottom