News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Post and PM Inline Attachments

Started by dougiefresh, July 26, 2014, 09:14:08 PM

Previous topic - Next topic

SaltedWeb

Will this work to put 2, photos side by side as opposed to vertical?
Knowing your limitations makes you human, exceeding these limitations makes you worthy of being human.

dougiefresh

@SaltedWeb:  If you don't use the download counter crap, then yes, it should work so that you can place 2 photos side-by-side, width permitting....  You will probably have to use the float parameters if you use the download counters.

SaltedWeb

Thank Dougie I found it was not comparable with one of my mods, i'll have to find another way to put them side by side.
I am really surprised by default there is not a vertical / horizontal option. As it forces one to use allot of space to make it look right.
Not speaking of your Mod I meant SMF I don't post pictures much but was going to do it and found it lines them all up in a row regardless of size. I think I finally found something on SMF I find annoying, looking back seems something asked allot and no real solutions I could find. Thanks
Knowing your limitations makes you human, exceeding these limitations makes you worthy of being human.

jakes_t

Side by side pictures would just over complicate things, especially for large pictures. A large thumbnail clickable to full along with this mod: https://www.simplemachines.org/community/index.php?topic=521231.0 (Resize pictures). This works very nicely for resizing pictures directly from phones and it corrects the orientation as well (which is broken on SMF).

GL700Wing

#764

Quote from: SaltedWeb on March 05, 2018, 06:02:23 PM
I'll have to find another way to put them side by side.
For inline images displayed within posts setting values for "Restrict images to maximum width of:" and "Restrict images to maximum height of:" to something like 240/180 or 320/240 keeps the images quite small horizontally when displayed in posts (especially if "Download link and counter setting:" is set to "Disabled") but you can still encounter horizontal spacing issues when images have long file names.

For thumbnail images displayed below posts I've been using Custom View of Attachments* since 2013 to display thumbnails side by side and it works perfectly on my SMF 2.0.15 forums.
Note: You must install the New Hooks package first.

After installing Custom View of Attachments* you'll need to edit ./Sources//Subs-CustomView.php and make the following change:
Find:
function custom_view_buffer(&$buffer)

Replace With:
function custom_view_buffer($buffer)


This is the list of packages I install (and this is the order I install them in) for image viewing in posts and PMs:
New Hooks
Custom View of Attachments
Highslide Image Viewer
PM Attachments
Post and PM Inline Attachments



* This mod used to be available here but is now only available from the developers website.
Life doesn't have to be perfect to be wonderful ...

GL700Wing

#765
Quote from: GL700Wing on March 09, 2018, 10:22:33 PM
... but you can still encounter horizontal spacing issues when images have long filenames.
After posting my previous message I realised that long filenames are truncated when using the Custom View of Attachments mod with the "In the line (horizontally)" option so I thought I'd have a go at implementing the same thing for this mod and also add the option for having just the filename and size/dimensions (ie, without the download count) displayed over two lines.

The following changes will display a link name to an image filename that is no wider than the displayed image size for an inline image and this will prevent long link names from taking up unnecessary horizontal space.  In addition, there is now an option to display the filename and size/dimensions over two lines.

Finally, and while it may seem logical to have the 'Filename, Size and Dimensions (2 Lines)' option displayed immediately after the 'Filename, Size and Dimensions' option in the drop-down list this would change the information that is displayed for people who have already selected one of the 'Filename, Size, Dimensions and Count' options.

In ./Themes/default/languages/InlineAttachmentsAdmin.english.php
Find:
$txt['ila_download_count_fsdc3'] = 'Filename, Size, Dimensions and Count (3 Lines)';
Add After:
$txt['ila_download_count_fsd2'] = 'Filename, Size and Dimensions (2 Lines)';


In ./Sources/Subs-InlineAttachmentsAdmin.php
Find:
$txt['ila_download_count_fsdc3']
Add After:
, $txt['ila_download_count_fsd2']


In ./Sources/Subs-InlineAttachments.php
Find:
// Let's build the HTML code for the download count now....
$html = (!empty($html) ? $html . '<br/>' : '') .
'<span class="smalltext">' .
'<a href="' . $attachment['href'] . '">' .
'<img src="' . $settings['images_url'] . '/icons/clip.' . (!isset($txt['attach_times']) ? 'png' : 'gif') . '" align="middle" alt="*" border="0" /> ' . $attachment['name'] .
'</a>' .

Replace with:
// Let's build the HTML code for the download count now....
$title = $attachment['name'];
$name = $title;
if ($attachment['is_image'])
{
if (!empty($modSettings['ila_max_width']))
$name = $dimensions['width'] < $modSettings['ila_max_width'] ? $smcFunc['substr']($attachment['name'], 0, round($dimensions['width']/7, 0)) : $smcFunc['substr']($attachment['name'], 0, round($modSettings['ila_max_width']/7, 0));
else
$name = $smcFunc['substr']($attachment['name'], 0, round($dimensions['width']/7, 0));
}

$html = (!empty($html) ? $html . '<br/>' : '') .
'<span class="smalltext">' .
'<img src="' . $settings['images_url'] . '/icons/clip.' . (!isset($txt['attach_times']) ? 'png' : 'gif') . '" align="middle" alt="*" border="0" /> ' .
'<a href="' . $attachment['href'] . '" title="' . $title . '">' . $name . '</a>' .


Find:
($download_count >= 4 ? (
Replace with:
($download_count >= 4 && $download_count <= 6 ? (
Life doesn't have to be perfect to be wonderful ...

GL700Wing

Life doesn't have to be perfect to be wonderful ...

dougiefresh

I've got these fixes added to the mod, with exception of the "truncation of long filename" fix.  I've come up with a different method of filename truncation via CSS.  However, I screwed up the language files and don't have time to fix them before I go to work.  So it'll probably be tomorrow sometime when the new mod gets released.

GL700Wing

Quote from: dougiefresh on March 10, 2018, 12:55:22 PM
I've got these fixes added to the mod, with exception of the "truncation of long filename" fix.  I've come up with a different method of filename truncation via CSS.  However, I screwed up the language files and don't have time to fix them before I go to work.  So it'll probably be tomorrow sometime when the new mod gets released.
Excellent - I did read about using CSS ellipsis for truncating long filenames but I didn't know how to go about implementing it for this mod although I did get it working for the Highslide mod I use.
Life doesn't have to be perfect to be wonderful ...

dougiefresh

#769
Uploaded v6.7 - March 15th, 2018
o Per GL700Wing: Add space on either side of each new inline attachment tag.
o Per GL700Wing: Fixed buffer issue in Sources/Subs-CustomView.php.
o Added CSS and code for a fix for truncating long filenames to picture width.
o Removed obsolete ILA.css file from the mod file list.
o Removed obsolete popup language strings.
o Added code to filter HTML tags from TXT files.
o Added admin option to disable filtering HTML from TXT files.




@Everybody:  Sorry it took so long.  Had to deal with too many damn computer problems....  Anyways, here the update is: a few days late, but better late than never....

@Rock Lee:  There are some language strings that need to be translated!  It would be appreciated if you could translate them.  They begin with //....

-Rock Lee-

#770
It is very nice to see how you are updating all your modifications really, that's why here I leave you updated also the translations with some improvements :)!


Regards!
¡Regresando como cual Fenix! ~ Bomber Code
Ayudas - Aportes - Tutoriales - Y mucho mas!!!

@rjen

Updated to the new version. I noticed that it has a dependency on the mod Automatic Attachment rotation (had to uninstall that one before updating this one)

I also noticed that in the newer version the paperclip icon and the attachment filename are on separate lines. Is that on purpose?

The previous version was more compact: paperclip icon on the same line as the attachment name. I liked that better...
Running SMF 2.1 with latest TinyPortal at www.fjr-club.nl

dougiefresh

Uploaded v6.8 - March 15th, 2018
o Included updated Subs-InlineAttachments.php file.
o Updated Spanish Latin translation by Rock Lee.



@Rock Lee:  Thank you for the updated translations!  They've been included in this version!

Quote from: @rjen on March 15, 2018, 02:26:41 PM
Updated to the new version. I noticed that it has a dependency on the mod Automatic Attachment rotation (had to uninstall that one before updating this one)
It's not so much a dependency on the mod, but both mods altering the same area of code.....

Quote from: @rjen on March 15, 2018, 02:26:41 PM
I also noticed that in the newer version the paperclip icon and the attachment filename are on separate lines. Is that on purpose?
No, evidentally I forgot to copy the updated files to the mod folder before I zipped everything up for distribution....

GL700Wing

I installed this mod and noticed that 'Size', 'Dimensions' and 'Count' are not always displayed when the truncated image name is the same width as the image the although they do display when the '2 lines' and '3 lines' options are selected.

The challenge is that the horizontal space required to display 'Size', 'Dimensions' and 'Count' can, in some instances, be the same as the image width (eg, when the image width or ILA max width is 240px or less) which means it may not actually be possible to display any of this additional information.

The following code change in ./Sources/Subs-InlineAttachments.php resolves this issue although it does mean that 'Size', 'Dimensions' and 'Count' will always be displayed on a second line even if neither of the '2 lines' options are chosen.  However, if one of the '2 lines'/'3 lines' options are chosen the additional lines will be displayed with tighter vertical spacing and better horizontal alignment.  It also fixes a couple of minor issues in relation to the information displayed for non-image attachments (eg, extra '-' scharacters).
Find:
// Let's build the HTML code for the download count now....
$title = $attachment['name'];
$name = $title;

$html = (!empty($html) ? $html . '<br/>' : '') .
'<div class="smalltext" style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis; width: ' . (!empty($modSettings['ila_max_width']) ? ($dimensions['width'] < $modSettings['ila_max_width'] ? $dimensions['width'] : $modSettings['ila_max_width']) : $dimensions['width']) . 'px;">' .
'<img src="' . $settings['images_url'] . '/icons/clip.' . (!isset($txt['attach_times']) ? 'png' : 'gif') . '" align="middle" alt="*" border="0" /> ' .
'<a href="' . $attachment['href'] . '" title="' . $title . '">' . $name . '</a>' .   ($download_count ? (
($download_count >= 5 ? '<br/>' : ' ') .
($download_count >= 2 ? '(' . $attachment['size'] : '') .
($download_count >= 3 && $attachment['is_image'] && !empty($dimensions['width']) ? ', ' . $dimensions['width'] . 'x' . $dimensions['height'] : '') .
($download_count >= 4 && $download_count <= 6 ? (
($download_count == 6 ? ')<br/>(' : ' - ') .
($attachment['is_image'] ? $viewed : ' - ' . $downloaded)
) : '') .
($download_count >= 2 ? ')' : '')
) : '') .
'</div>';


Replace With:
// Let's build the HTML code for the download count now....
$html = (!empty($html) ? $html . '<br/>' : '') .
'<span class="smalltext" style="display:block; ' . ($attachment['is_image'] ? 'max-' : '') . 'width:' . ($attachment['is_image'] && $dimensions['width'] > 0 ? (!empty($modSettings['ila_max_width']) && $modSettings['ila_max_width'] < $dimensions['width'] ? $modSettings['ila_max_width'] : $dimensions['width']) : 240) . 'px;">' .
'<img style="float:left; margin-top:0.5em;" src="' . $settings['images_url'] . '/icons/clip.' . (!isset($txt['attach_times']) ? 'png' : 'gif') . '" align="middle" alt="*" /> ' .
'<a style="display:block; margin-left:1.2em; white-space:nowrap; overflow:hidden; text-overflow:ellipsis" href="' . $attachment['href'] . '" title="' . $attachment['name'] . '">' . $attachment['name'] . '</a>' .
($download_count ? (
($download_count >= 5 ? '</span><br/><span class="smalltext" style="display:block; padding-left:1.2em; margin-top:-2.0em;">' : ' ') .
($download_count >= 2 ? '(' . $attachment['size'] : '') .
($download_count >= 3 && $attachment['is_image'] && !empty($dimensions['width']) ? ', ' . $dimensions['width'] . 'x' . $dimensions['height'] : '') .
($download_count >= 4 && $download_count <= 6 ? (
($download_count == 6 ? ')</span><br/><span class="smalltext" style="display:block; padding-left:1.2em; margin-top:-2.0em;">(' : ' - ') .
($attachment['is_image'] ? $viewed : $downloaded)
) : '') .
($download_count >= 2 ? ')' : '')
) : '') .
'</span>';



BTW:  The reason I test for image width greater than zero (and assign a width if necessary) is because I recently discovered I have images with '0' dimensions in a database which was converted from vBulletin.  I don't know if the images actually exist and/or are referenced in any messages but I figured it's safer to assign a width rather than run the risk of generating error messages.  Also, assigning a width for non-image attachments (eg, text and PDF files) means their file names are also truncated which I think is a nice side-effect.
Life doesn't have to be perfect to be wonderful ...

GL700Wing

*Bump*

I know you've been busy writing other mods ;) and you now also have a GitHub issue to deal with but I thought I'd bump this just in case you haven't already seen my previous post.
Life doesn't have to be perfect to be wonderful ...

pepa

Is this mod compatible with (and works with) the Mod - Resize Attached Images Ver. 2.4.1?

GL700Wing

Quote from: pepa on March 19, 2018, 02:28:44 AM
Is this mod compatible with (and works with) the Mod - Resize Attached Images Ver. 2.4.1?
Yep - I have both mods installed and working together on two SMF 2.0.15 forums.
Life doesn't have to be perfect to be wonderful ...

pepa

Quote from: GL700Wing on March 19, 2018, 04:29:41 AM
Quote from: pepa on March 19, 2018, 02:28:44 AM
Is this mod compatible with (and works with) the Mod - Resize Attached Images Ver. 2.4.1?
Yep - I have both mods installed and working together on two SMF 2.0.15 forums.

Thanks for your reply GL700Wing : ).  I'll take it out for a test drive.

dougiefresh

Uploaded v6.9 - March 20th, 2018
o Changed HTML download count building code, based on GL700's post.




@GL700Wing:  Very interesting!  The fix is included in this release!  Thanks again for your contribution!

GL700Wing

Quote from: dougiefresh on March 22, 2018, 08:54:25 PM
@GL700Wing:  Very interesting!  The fix is included in this release!  Thanks again for your contribution!
You're welcome.
Life doesn't have to be perfect to be wonderful ...

Advertisement: