Place Inline Attachment Spacing

Need some custom code changes to the phpBB core simple enough that you feel doesn't require an extension? Then post your request here so that community members can provide some assistance.

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Post Reply
profKroy
Registered User
Posts: 130
Joined: Sun Feb 14, 2016 2:39 pm

Place Inline Attachment Spacing

Post by profKroy » Tue Apr 23, 2019 6:11 pm

I'm noticing (and getting annoyed) that when my students attach and image then "place inline" that there is not sufficient margin above and below the image in the post, even though they may add a carriage return to create space between the text and image. Prosilver btw

In other words, you have to carriage return twice in order to create a margin to separate text above and below an image that is "placed inline. The issue is with regard to post layout and obviously usability i.e. matching the post to what is written in the post (authoring) screen.

Can someone PM me, or reply, where I can go to make an adjustment to the code, or recommend a work around? I'm having to go back and edit a lot of posts to keep my image heavy forum tidy and readable. Thank you!



For example, this...(2 carriage returns = 1 space margin)

image.jpg
image.jpg (45.91 KiB) Viewed 583 times


I don't prefer this. (1 carriage return space - no margin)
image.jpg
image.jpg (45.91 KiB) Viewed 583 times


See below...there is a mismatch between what's presented in the post screen and what's displayed. One space should display one space.

Code: Select all


For example, this...(2 carriage returns = 1 space margin)


[attachment=0]image.jpg[/attachment]



I don't prefer this. (1 carriage return space - no margin)

[attachment=0]image.jpg[/attachment]


Are you a skilled extension developer? I need an extension developed right now. Here are the general specs. Please PM me if interested.

User avatar
EA117
Registered User
Posts: 641
Joined: Wed Aug 15, 2018 3:23 am
Contact:

Re: Place Inline Attachment Spacing

Post by EA117 » Tue Apr 23, 2019 7:24 pm

You're not alone in wishing that default behavior was different, and that "a blank line between my last paragraph and the inline attachment" resulted in a blank line between the actual rendered paragraph and rendered attachment. But there is something in the message parsing that is "eating" the blank line immediately before and after the inline attachment, such that this source message pseudo-code:

Code: Select all

...previous paragraph ends.<enter>
<enter>
[inline image]
<enter>
Next paragraph starts....<enter>
Ends up being rendered as:

Code: Select all

...previous paragraph ends.<br>

<div class="inline-attachment">...</div>

Next paragraph starts....<br>
So what would normally have resulted in an additional HTML <br> code being emitted, instead has at least a single instance (1) of the "<br><br>" pairs collapsed into a single "<br>", even though additional end-of-lines added to the message will not be collapsed in that manner. You ultimately have to put three (3) end-of-line markers in the message, in order to produce the two (2) <br> codes you're otherwise expecting to become emitted.

What you can do today of course is simply adjust the CSS for inline-attachment elements, to give extra top and bottom margin to compensate for the absence of the <br> that we know won't be "honored" or emitted. The trade-off is that then you can never put the image right up against the text, even in the cases where you would have wanted to & omitted the extra line when typing your message.

So this is really just a workaround, and just exchanges "one fixed behavior for a different fixed behavior." When the correct solution would be to honor whatever number of lines were actually typed in the message. But changing the CSS might at least get you a more pleasing default in your specific case, and be "good enough."

Due to the number of posts that were already "fixed" by adding additional end-of-lines in the message source, I've never been brave enough to go change our CSS to force the extra space. Since then I would feel like I need to go back and "fix" every existing message in the opposite direction, to remove the additional end-of-lines that weren't supposed to be necessary in the first place.

Note we're specifically talking about changing the existing /styles/prosilver/theme/content.css definition of how dl.thumbnail and dl.file will be rendered as part of inline-attachment:

Code: Select all

/* Inline image thumbnails */
div.inline-attachment dl.thumbnail, div.inline-attachment dl.file {
	display: block;
	margin-bottom: 4px;
}
into something like:

Code: Select all

/* Inline image thumbnails */
div.inline-attachment dl.thumbnail, div.inline-attachment dl.file {
    display: block;
    margin-bottom: 1em;
    margin-top: 1em;
}

profKroy
Registered User
Posts: 130
Joined: Sun Feb 14, 2016 2:39 pm

Re: Place Inline Attachment Spacing

Post by profKroy » Tue Apr 23, 2019 9:16 pm

Thank you for your detailed response. This helps immensely in understanding the mechanics of what on going on....causes and solution.

I think adjusting the CSS to add the margins will be the best solution. For my specific situation I don't see the necessity to ever have (top) text up against the image beneath. I'm not using the image name/views caption below the image either, where the margin would be less desirable. I can see the CSS solution being an issue there perhaps, for some who want a caption be in close proximity of the image being captioned.

Thanks again, this really helps to keep my board looking it's best. Now if I could only get my students to "Place Inline" all the images they post!

Hey....extension idea! Auto-Place Inline Image Attachments. That would be game changer too!
Are you a skilled extension developer? I need an extension developed right now. Here are the general specs. Please PM me if interested.

Post Reply

Return to “phpBB Custom Coding”