Advertisement:

Author Topic: Post and PM Inline Attachments  (Read 185900 times)

Offline SaltedWeb

  • Sr. Member
  • ****
  • Posts: 859
  • Gender: Male
  • The Tired One
Re: Post and PM Inline Attachments
« Reply #760 on: March 04, 2018, 03:00:28 PM »
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.

Offline dougiefresh

  • SMF Hero
  • ******
  • Posts: 2,815
  • Mod King
    • XPtsp.com Community
Re: Post and PM Inline Attachments
« Reply #761 on: March 04, 2018, 10:14:11 PM »
@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.

Offline SaltedWeb

  • Sr. Member
  • ****
  • Posts: 859
  • Gender: Male
  • The Tired One
Re: Post and PM Inline Attachments
« Reply #762 on: March 05, 2018, 06:02:23 PM »
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.

Offline jakes_t

  • Semi-Newbie
  • *
  • Posts: 30
Re: Post and PM Inline Attachments
« Reply #763 on: March 09, 2018, 06:19:04 PM »
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).

Offline GL700Wing

  • Full Member
  • ***
  • Posts: 441
  • Gender: Female
Re: Post and PM Inline Attachments
« Reply #764 on: March 09, 2018, 10:22:33 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:
Code: [Select]
function custom_view_buffer(&$buffer)
Replace With:
Code: [Select]
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.
« Last Edit: March 09, 2018, 10:48:11 PM by GL700Wing »

Offline GL700Wing

  • Full Member
  • ***
  • Posts: 441
  • Gender: Female
Re: Post and PM Inline Attachments
« Reply #765 on: March 10, 2018, 02:34:16 AM »
... 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:
Code: [Select]
$txt['ila_download_count_fsdc3'] = 'Filename, Size, Dimensions and Count (3 Lines)';Add After:
Code: [Select]
$txt['ila_download_count_fsd2'] = 'Filename, Size and Dimensions (2 Lines)';

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

In ./Sources/Subs-InlineAttachments.php
Find:
Code: [Select]
// 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:
Code: [Select]
// 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:
Code: [Select]
($download_count >= 4 ? (Replace with:
Code: [Select]
($download_count >= 4 && $download_count <= 6 ? (
« Last Edit: March 10, 2018, 03:25:05 AM by GL700Wing »

Offline GL700Wing

  • Full Member
  • ***
  • Posts: 441
  • Gender: Female
Re: Post and PM Inline Attachments
« Reply #766 on: March 10, 2018, 04:50:15 AM »

Offline dougiefresh

  • SMF Hero
  • ******
  • Posts: 2,815
  • Mod King
    • XPtsp.com Community
Re: Post and PM Inline Attachments
« Reply #767 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.

Offline GL700Wing

  • Full Member
  • ***
  • Posts: 441
  • Gender: Female
Re: Post and PM Inline Attachments
« Reply #768 on: March 10, 2018, 01:28:06 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.

Offline dougiefresh

  • SMF Hero
  • ******
  • Posts: 2,815
  • Mod King
    • XPtsp.com Community
Re: Post and PM Inline Attachments
« Reply #769 on: March 15, 2018, 11:21:10 AM »
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 //....
« Last Edit: March 15, 2018, 12:07:07 PM by dougiefresh »

Offline Rock Lee

  • Native Language Support Specialist
  • SMF Hero
  • *
  • Posts: 2,039
  • Gender: Male
  • I also speak english :D
    • BomberCode.Oficial on Facebook
    • RockLee-BC on GitHub
    • @Bomber_Code on Twitter
    • Bomber Code ~ La nueva era del conocimiento
Re: Post and PM Inline Attachments
« Reply #770 on: March 15, 2018, 12:40:38 PM »
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!
« Last Edit: March 15, 2018, 12:52:25 PM by Rock Lee »
¡Regresando como cual Fenix! ~ Bomber Code © 2018
Ayudas - Aportes - Tutoriales - Y mucho mas!!!


Ayudame via PayPal

Offline @rjen

  • Jr. Member
  • **
  • Posts: 286
  • Gender: Male
Re: Post and PM Inline Attachments
« Reply #771 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)

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.0 with Tinyportal 1.6.0 at www.fjr-club.nl
Testing SMF 2.1 beta 4 with Tinyportal 1.6.1 at http://test2.fjr-club.nl/

Offline dougiefresh

  • SMF Hero
  • ******
  • Posts: 2,815
  • Mod King
    • XPtsp.com Community
Re: Post and PM Inline Attachments
« Reply #772 on: March 15, 2018, 05:45:51 PM »
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!

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.....

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....

Offline GL700Wing

  • Full Member
  • ***
  • Posts: 441
  • Gender: Female
Re: Post and PM Inline Attachments
« Reply #773 on: March 16, 2018, 01:19:28 AM »
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:
Code: [Select]
// 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:
Code: [Select]
// 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.

Offline GL700Wing

  • Full Member
  • ***
  • Posts: 441
  • Gender: Female
Re: Post and PM Inline Attachments
« Reply #774 on: March 18, 2018, 11:51:56 AM »
*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.

Offline pepa

  • Jr. Member
  • **
  • Posts: 192
Re: Post and PM Inline Attachments
« Reply #775 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?

Offline GL700Wing

  • Full Member
  • ***
  • Posts: 441
  • Gender: Female
Re: Post and PM Inline Attachments
« Reply #776 on: March 19, 2018, 04:29:41 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.

Offline pepa

  • Jr. Member
  • **
  • Posts: 192
Re: Post and PM Inline Attachments
« Reply #777 on: March 19, 2018, 05:51:46 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.

Offline dougiefresh

  • SMF Hero
  • ******
  • Posts: 2,815
  • Mod King
    • XPtsp.com Community
Re: Post and PM Inline Attachments
« Reply #778 on: March 22, 2018, 08:54:25 PM »
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!

Offline GL700Wing

  • Full Member
  • ***
  • Posts: 441
  • Gender: Female
Re: Post and PM Inline Attachments
« Reply #779 on: March 25, 2018, 01:58:30 AM »
@GL700Wing:  Very interesting!  The fix is included in this release!  Thanks again for your contribution!
You're welcome.