• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

XF 1.5 Inserting one or more line break(s) after [ATTACH]

ehd

Active member
#1
Hi,

when you insert attachtments into the post, they always get inserted like this:

Code:
[ATTACH=full]1553593[/ATTACH] [ATTACH=full]1553594[/ATTACH] [ATTACH=full]1553595[/ATTACH] [ATTACH=full]1553596[/ATTACH] [ATTACH=full]1553597[/ATTACH] [ATTACH=full]1553598[/ATTACH]
Is there a way to insert one or more linebreaks after each attachment, so there is more space between the images? At least I couldn't find an add-on for it.

Thanks!
 

Mike

XenForo developer
Staff member
#2
There wouldn't be a direct way of changing how they're inserted. You could potentially adjust the bb_code_tag_attach template and wrap the output in a <div>...</div>, though you'll be forcing each attachment to be displayed on its own line which may not be desirable.
 

AndyB

Well-known member
#4
Is there a way to insert one or more linebreaks after each attachment
This is what I do, however it's a code hack and is required for me to apply it every time I upgrade XenForo.

Code:
/js/xenforo/full/attachment_editor_new.js

While editing a message, always show attachments as code instead of image and attach code one per line.
			
line #532
			if ($trigger.attr('name') == 'thumb')
			{
				bbcode = '[ATTACH]' + attachmentId + '[/ATTACH] ';
				html = '<img src="' + thumb + '" class="attachThumb bbCodeImage" alt="attachThumb' + attachmentId + '" /> ';
			}
			else
			{
				//bbcode = '[ATTACH=full]' + attachmentId + '[/ATTACH] ';
				//html = '<img src="' + img + '" class="attachFull bbCodeImage" alt="attachFull' + attachmentId + '" /> ';
				bbcode = '[ATTACH=full]' + attachmentId + '[/ATTACH]' + '\r\n\r\n';
				html = '[ATTACH=full]' + attachmentId + '[/ATTACH]' + '<br /><br />';			
			}
Note, I don't allow thumbs and that's why I don't bother hacking the part of the code that deals with thumbs.
 

Floyd R Turbo

Well-known member
#6
There wouldn't be a direct way of changing how they're inserted. You could potentially adjust the bb_code_tag_attach template and wrap the output in a <div>...</div>, though you'll be forcing each attachment to be displayed on its own line which may not be desirable.
Would one be able to manually remove the line breaks via the bbcode editor before posting, or edit the post afterwards, in order to remove line breaks if desired?

I'm not sure if I'm just the only one here but I never see the need for inserting attachments inline with text. Esp pics.

Literally, in 10+ years of posting on forums, I can't think of one instance in which I wanted a pic to not appear on it's own line
 

Sunka

Well-known member
#7
Same problem on my forum.
I always had to edit posts of users to move image/attachment in new row. I suggested to my users same, finish the text, press twice neter, insert image, press enter twice again, add some other text.

Also when there is more than one image in row, I put them into one row.
 

Floyd R Turbo

Well-known member
#10
You could potentially adjust the bb_code_tag_attach template and wrap the output in a <div>...</div>
@Mike can you specify the mod that you are describing here? Are you saying to wrap the entire template in the div tags?

though you'll be forcing each attachment to be displayed on its own line which may not be desirable.
This is actually precisely what I want. What would I change and where to achieve this?

Code:
<xen:if is="!{$validAttachment}">

    <a href="{xen:link full:attachments, $attachment}" target="_blank">{xen:phrase view_attachment_x, 'name={$attachment.attachment_id}'}</a>
    
<xen:elseif is="!{$attachment.thumbnailUrl}" />

    <a href="{xen:link full:attachments, $attachment}" target="_blank">{xen:phrase view_attachment_x, 'name={$attachment.filename}'}</a>
    
<xen:elseif is="{$canView} AND {$full}" />
    
    <img src="{xen:link full:attachments, $attachment}" alt="{$attachment.filename}" class="bbCodeImage LbImage" />
        
<xen:elseif is="{$canView}" />
    
    <a href="{xen:link full:attachments, $attachment}" target="_blank" class="LbTrigger"
        data-href="{xen:link misc/lightbox}"><img
        src="{$attachment.thumbnailUrl}" alt="{$attachment.filename}"
        class="bbCodeImage LbImage" /></a>
            
<xen:else />

    <a href="{xen:link full:attachments, $attachment}" target="_blank"><img src="{$attachment.thumbnailUrl}" alt="{$attachment.filename}" class="bbCodeImage" /></a>
    
</xen:if>
 

Mike

XenForo developer
Staff member
#11
Yes, just literally wrap the entire template in a <div> (and then </div>). Note that this won't apply during editing/posting though.
 

Floyd R Turbo

Well-known member
#12
Yes, just literally wrap the entire template in a <div> (and then </div>). Note that this won't apply during editing/posting though.
That's actually perfect....I can apply my "default" preferences and then if someone wants their own format, they can modify it. Thanks!!!
 
Last edited: