Advertisement:

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

Offline Parmaster

  • Newbie
  • *
  • Posts: 5
Re: Post and PM Inline Attachments
« Reply #660 on: September 13, 2017, 07:12:24 AM »
Hi!

I Installed successfully your mod, but I can't insert an attachment. I see the links but when I click on it nothing happens.

And in PM's it's not possible to send an attachment.

And why is in every PHP file which the mod edited this CDATA? It seems that there is a failure with editing the files. Or doesn't it affect anything?

Offline dougiefresh

  • SMF Hero
  • ******
  • Posts: 2,358
    • XPtsp.com Community
Re: Post and PM Inline Attachments
« Reply #661 on: September 14, 2017, 11:32:39 AM »
@dougie, i noticed that you handle pdf files in some way (was looking at the settings) but i have attached both pdf and text files but there was no display unlike your picture processing.
Evidentally, Google has changed their software so that you HAVE to be logged in in order to view a PDF document.  I am going to change the code to use an embed or object HTML tag, which may require the user to have Adobe Reader installed on the system....

I Installed successfully your mod, but I can't insert an attachment. I see the links but when I click on it nothing happens.
Hmmmmm.....  Let me look into this.

And in PM's it's not possible to send an attachment.
This mod doesn't give the forum the ability to sent PM attachments, but enhances the PM Attachments mod to allow you to insert the attachment into the message, much like using the img tag.

And why is in every PHP file which the mod edited this CDATA? It seems that there is a failure with editing the files. Or doesn't it affect anything?
Huh?
NOTICE:  My website is back up!

My Free Simple Machines mods on XPtsp.com and Simple Machines Customization Site!
My mods are being uploaded and are available at GitHub as well!

Offline pellet_newb

  • Semi-Newbie
  • *
  • Posts: 18
Re: Post and PM Inline Attachments
« Reply #662 on: September 14, 2017, 11:37:26 AM »
What about Tapatalk support?

Offline Parmaster

  • Newbie
  • *
  • Posts: 5
Re: Post and PM Inline Attachments
« Reply #663 on: September 14, 2017, 11:41:53 AM »
@dougiefresh:

don't worry, I solved it. I don't know if it's related to the theme I use or SMF directly, but it only works if WYSIWYG is off (in my forum).

Ah ok, then I have to look about this mod.

It wasn't your mod alone that included the CDATA crap into the files, I saw many of them also in other files in which your mod haven't changed anything, so something is broken and I don't know what.

Offline dougiefresh

  • SMF Hero
  • ******
  • Posts: 2,358
    • XPtsp.com Community
Re: Post and PM Inline Attachments
« Reply #664 on: September 14, 2017, 11:51:18 AM »
What about Tapatalk support?
Still looking into it.
NOTICE:  My website is back up!

My Free Simple Machines mods on XPtsp.com and Simple Machines Customization Site!
My mods are being uploaded and are available at GitHub as well!

Offline dougiefresh

  • SMF Hero
  • ******
  • Posts: 2,358
    • XPtsp.com Community
Re: Post and PM Inline Attachments
« Reply #665 on: September 15, 2017, 11:41:51 PM »
What about Tapatalk support?
UPDATE:  My forum is now online with Tapatalk, so I can now do testing with it to try to make it work with this mod.
NOTICE:  My website is back up!

My Free Simple Machines mods on XPtsp.com and Simple Machines Customization Site!
My mods are being uploaded and are available at GitHub as well!

Offline pellet_newb

  • Semi-Newbie
  • *
  • Posts: 18
Re: Post and PM Inline Attachments
« Reply #666 on: September 17, 2017, 07:31:01 PM »
What about Tapatalk support?
UPDATE:  My forum is now online with Tapatalk, so I can now do testing with it to try to make it work with this mod.

SWEET, fingers crossed!

Offline pellet_newb

  • Semi-Newbie
  • *
  • Posts: 18
Re: Post and PM Inline Attachments
« Reply #667 on: September 26, 2017, 11:33:49 AM »
Have you made any progress with Tapatalk?  Thanks

Online GL700Wing

  • Jr. Member
  • **
  • Posts: 253
  • Gender: Female
Re: Post and PM Inline Attachments
« Reply #668 on: October 02, 2017, 01:03:47 AM »
Found an issue that results in the wrong error message (ie, '] Invalid Attachment [' instead of '[ Attachment has not been uploaded yet ]') being displayed when previewing either a new or modified message that includes a new inline attachment.  Fixed by moving a slightly modified preview message test to before the permissions tests.

Also, suggest that test for determining if attachments can be viewed is done at very beginning so that 'ila_nopermission' message is displayed instead of 'ila_invalid' message.

In /.Sources/Subs-InlineAttachments.php

Find:
Code: [Select]
function ILA_Build_HTML(&$tag, &$id)
{
global $context, $modSettings, $settings, $txt, $sourcedir, $user_info, $smcFunc, $forum_version;

// If the "one-based numbering" option is set, subtract 1 from the attachment ID to make it compatible:
$id = $id - intval(!empty($modSettings['ila_one_based_numbering']));

// Make sure that we can access other messages:
$allowed = (isset($modSettings['ila_allow_quoted_images']) && !empty($modSettings['ila_allow_quoted_images']) && !file_exists($sourcedir . '/Subs-Tapatalk.php'));
if (isset($context['ila_params']['msg']))
$msg = ($allowed || (isset($context['ila']['msg']) && $context['ila_params']['msg'] == $context['ila']['msg']) ? $context['ila_params']['msg'] : -1);
else
$msg = (isset($context['ila']['msg']) ? $context['ila']['msg'] : -1);

// Are attachments enabled and can we see them?  If not, return no permission message:
if (!isset($context['ila']['attachments'][$msg][$id]))
return $txt['ila_invalid'];
$attachment = &$context['ila']['attachments'][$msg][$id];
if (empty($context['ila']['pm_attach']) && empty($modSettings['attachmentEnable']))
return $txt['ila_nopermission'];
if (!empty($context['ila']['pm_attach']) && (empty($modSettings['pmAttachmentEnable']) || empty($context['ila']['pm_view_attachments'])))
return $txt['ila_nopermission'];

// This part is done after board permission check because we don't want to give user false hope.
// If we are previewing the post, return "attachment not uploaded yet" message:
if (!isset($context['ila']['attachments'][$msg]) && (isset($_REQUEST['action']) ? $_REQUEST['action'] : '') == 'post2')
return $txt['ila_not_uploaded'];

Replace With:
Code: [Select]
function ILA_Build_HTML(&$tag, &$id)
{
global $context, $modSettings, $settings, $txt, $sourcedir, $user_info, $smcFunc, $forum_version;

// Are we allowed to view attachments?  If not, return no permission message
if (!allowedTo('view_attachments'))
return $txt['ila_nopermission'];

// If the "one-based numbering" option is set, subtract 1 from the attachment ID to make it compatible:
$id = $id - intval(!empty($modSettings['ila_one_based_numbering']));

// Make sure that we can access other messages:
$allowed = (isset($modSettings['ila_allow_quoted_images']) && !empty($modSettings['ila_allow_quoted_images']) && !file_exists($sourcedir . '/Subs-Tapatalk.php'));
if (isset($context['ila_params']['msg']))
$msg = ($allowed || (isset($context['ila']['msg']) && $context['ila_params']['msg'] == $context['ila']['msg']) ? $context['ila_params']['msg'] : -1);
else
$msg = (isset($context['ila']['msg']) ? $context['ila']['msg'] : -1);

// If we are previewing the post, return "attachment not uploaded yet" message:
if (((isset($_REQUEST['action']) ? $_REQUEST['action'] : '') == 'post2') && (!isset($context['ila']['attachments'][$msg][$id])))
return $txt['ila_not_uploaded'];

// Are attachments enabled and can we see them?  If not, return no permission message:
if (!isset($context['ila']['attachments'][$msg][$id]))
return $txt['ila_invalid'];
$attachment = &$context['ila']['attachments'][$msg][$id];
if (empty($context['ila']['pm_attach']) && empty($modSettings['attachmentEnable']))
return $txt['ila_nopermission'];
if (!empty($context['ila']['pm_attach']) && (empty($modSettings['pmAttachmentEnable']) || empty($context['ila']['pm_view_attachments'])))
return $txt['ila_nopermission'];

// This part is done after board permission check because we don't want to give user false hope.

Also, found a bug in 5.10 that is not present in 5.6 whereby a new attachment is not inserted inline when an existing message is modified - it is only attached (see attachments).

Offline dougiefresh

  • SMF Hero
  • ******
  • Posts: 2,358
    • XPtsp.com Community
Re: Post and PM Inline Attachments
« Reply #669 on: October 18, 2017, 11:41:41 PM »
Uploaded v5.11 - October 18th, 2017
o Modified code to return already-build attachment context array if available.
o Fixed reporting invalid attachment when viewing attachments on board wasn't possible.



@GL700Wing:  Thanks for reporting those bugs. 

The suggested code change would solve the immediate issue of the message, but it wouldn't solve this particular scenario: On a board where viewing attachments isn't possible, a message containing an inline attachment tag, which referrs to an attachment on a board where viewing attachments is allowed, would not be viewable, despite the fact that it is viewable on that board.  I've fixed the code in several spots to fix the whole issue on order to deal with the scenario specified.....

Also, found a bug in 5.10 that is not present in 5.6 whereby a new attachment is not inserted inline when an existing message is modified - it is only attached (see attachments).
Okay, that's weird....  I'll have to look into this bug report....

Have you made any progress with Tapatalk?  Thanks
@pellet_newb: I wish I could say that I have definitely made some progress, however, I THINK I've fixed an issue that keeps from reporting the attachments correctly to the Tapatalk script....  I haven't have time to test it against Tapatalk code, though....

I strongly suspect that since the Tapatalk mod does it's own parsing before and after called SMF's parsing function, that it is somehow messing up the attachments.  Not sure, though....
« Last Edit: October 18, 2017, 11:55:29 PM by dougiefresh »
NOTICE:  My website is back up!

My Free Simple Machines mods on XPtsp.com and Simple Machines Customization Site!
My mods are being uploaded and are available at GitHub as well!

Offline @rjen

  • Jr. Member
  • **
  • Posts: 165
  • Gender: Male
    • FJR-club Nederland
Re: Post and PM Inline Attachments
« Reply #670 on: October 19, 2017, 09:06:09 AM »
Nice work, I was just wondering: did you ever find time to look into the incorrect presentation thing I reported before when two attachments are posted side by side? I tried finding a solution myself, but I was not successfull...

Issue Number 2:
I cannot seem to get two attachments showing next to each other: the attachment information seems to break the alignment, is there a solution for this?

If I deactivate the 'Download link and counter setting:' in admin it works, but when I activate it I get below display
Running SMF 2.0 with Tinyportal 1.3R at www.fjr-club.nl
Testing SMF 2.1 beta 3 with Tinyportal 2.0 at http://test2.fjr-club.nl/

Offline dougiefresh

  • SMF Hero
  • ******
  • Posts: 2,358
    • XPtsp.com Community
Re: Post and PM Inline Attachments
« Reply #671 on: October 19, 2017, 11:01:20 AM »
Nice work, I was just wondering: did you ever find time to look into the incorrect presentation thing I reported before when two attachments are posted side by side? I tried finding a solution myself, but I was not successfull...

Issue Number 2:
I cannot seem to get two attachments showing next to each other: the attachment information seems to break the alignment, is there a solution for this?

If I deactivate the 'Download link and counter setting:' in admin it works, but when I activate it I get below display
The only thing I've come up with for this is to use the float=left parameter in the inline attachment tag for both tags.....  The biggest problem that I can see with this solution is if text is involved, as floating the image to the left or right may screw with the intented appearance.....

You could also try a table declaration, surrounding each image with the [tr] tags.....

Also, found a bug in 5.10 that is not present in 5.6 whereby a new attachment is not inserted inline when an existing message is modified - it is only attached (see attachments).
Issue confirmed with version 5.11.
« Last Edit: October 19, 2017, 11:14:08 AM by dougiefresh »
NOTICE:  My website is back up!

My Free Simple Machines mods on XPtsp.com and Simple Machines Customization Site!
My mods are being uploaded and are available at GitHub as well!

Offline @rjen

  • Jr. Member
  • **
  • Posts: 165
  • Gender: Male
    • FJR-club Nederland
Re: Post and PM Inline Attachments
« Reply #672 on: October 19, 2017, 11:16:37 AM »
Problem is that I Cannot find where to do that...
Running SMF 2.0 with Tinyportal 1.3R at www.fjr-club.nl
Testing SMF 2.1 beta 3 with Tinyportal 2.0 at http://test2.fjr-club.nl/

Offline dougiefresh

  • SMF Hero
  • ******
  • Posts: 2,358
    • XPtsp.com Community
Re: Post and PM Inline Attachments
« Reply #673 on: October 19, 2017, 01:20:23 PM »
Insert float=left just after the id parameter.  That should work....
NOTICE:  My website is back up!

My Free Simple Machines mods on XPtsp.com and Simple Machines Customization Site!
My mods are being uploaded and are available at GitHub as well!

Offline @rjen

  • Jr. Member
  • **
  • Posts: 165
  • Gender: Male
    • FJR-club Nederland
Re: Post and PM Inline Attachments
« Reply #674 on: October 19, 2017, 01:29:54 PM »
Can you tell me what file the dit needs to be in?
Running SMF 2.0 with Tinyportal 1.3R at www.fjr-club.nl
Testing SMF 2.1 beta 3 with Tinyportal 2.0 at http://test2.fjr-club.nl/

Offline dougiefresh

  • SMF Hero
  • ******
  • Posts: 2,358
    • XPtsp.com Community
Re: Post and PM Inline Attachments
« Reply #675 on: October 19, 2017, 08:42:53 PM »
In the message that you are inlining an attachment.  Change something like this:
Code: (Starting Example) [Select]
[attachment id=1 msg=1234]to something like this:
Code: (Change to) [Select]
[attachment id=1 float=left msg=1234]
NOTICE:  My website is back up!

My Free Simple Machines mods on XPtsp.com and Simple Machines Customization Site!
My mods are being uploaded and are available at GitHub as well!

Offline @rjen

  • Jr. Member
  • **
  • Posts: 165
  • Gender: Male
    • FJR-club Nederland
Re: Post and PM Inline Attachments
« Reply #676 on: October 20, 2017, 02:58:14 AM »
In the message that you are inlining an attachment.  Change something like this:
Code: (Starting Example) [Select]
[attachment id=1 msg=1234]to something like this:
Code: (Change to) [Select]
[attachment id=1 float=left msg=1234]

That does the trick indeed, thanks! I was hoping for a more 'permanent'  fix though.

I now notice that when I include this float statement within the [ attachment ] code, an additional < div > is generated under the < inner > div.
This  div is what I was looking for: <div style="float: left;">

Without the style added into the attachment statement this div is not even generated, so there is nothing to influence from css.
Is there a way to always generate this div with the style so users will not have to manually type this additional float?
Running SMF 2.0 with Tinyportal 1.3R at www.fjr-club.nl
Testing SMF 2.1 beta 3 with Tinyportal 2.0 at http://test2.fjr-club.nl/

Offline @rjen

  • Jr. Member
  • **
  • Posts: 165
  • Gender: Male
    • FJR-club Nederland
Re: Post and PM Inline Attachments
« Reply #677 on: October 20, 2017, 05:05:21 AM »
I now notice that when I include this float statement within the [ attachment ] code, an additional < div > is generated under the < inner > div.
This  div is what I was looking for: <div style="float: left;">

Without the style added into the attachment statement this div is not even generated, so there is nothing to influence from css.
Is there a way to always generate this div with the style so users will not have to manually type this additional float?

mmm, I just realized the float is not ideal, because it would make all text float around the inline attachments permanently.
It would probably be better to have a standard <div> around the img and text defined as inline-block?
Running SMF 2.0 with Tinyportal 1.3R at www.fjr-club.nl
Testing SMF 2.1 beta 3 with Tinyportal 2.0 at http://test2.fjr-club.nl/

Offline @rjen

  • Jr. Member
  • **
  • Posts: 165
  • Gender: Male
    • FJR-club Nederland
Re: Post and PM Inline Attachments
« Reply #678 on: October 20, 2017, 07:59:03 AM »
I managed to make the change myself!
This fix does exactly what I was looking for: it by default creates the < div > as an inline-block, but when a float is used it works as a floated div. This way when a user puts three attachments on one line they will nicely show on the line without the text issues I highlighted. On smaller screens the divs are positioned below each other if needed.

You may want to include this in your next update as well?

In file: Subs-InlineAttachments.php

Find:
Code: [Select]
// Add the margin and float params to the rest of the HTML:
if (isset($context['ila_params']['float']) && $context['ila_params']['float'] == 'center')

Replace with:
Code: [Select]
// Add the margin and float params to the rest of the HTML:
if (!isset($context['ila_params']['float']))
$html = '<div style="display: inline-block;">' . $html . '</div>';
elseif (isset($context['ila_params']['float']) && $context['ila_params']['float'] == 'center')

See attachments...
Running SMF 2.0 with Tinyportal 1.3R at www.fjr-club.nl
Testing SMF 2.1 beta 3 with Tinyportal 2.0 at http://test2.fjr-club.nl/

Offline dougiefresh

  • SMF Hero
  • ******
  • Posts: 2,358
    • XPtsp.com Community
Re: Post and PM Inline Attachments
« Reply #679 on: October 20, 2017, 11:18:18 AM »
Hmmm.....  Code seems to work well enough, but I made another change to ensure other CSS style stuff gets included as well.  Here is that block of code:
Code: [Select]
// Add the margin and float params to the rest of the HTML:
if (isset($context['ila_params']['float']) && $context['ila_params']['float'] == 'center')
$html = '<div style="margin-left: auto; margin-right: auto; display: block;">' . $html . '</div>';
elseif (isset($context['ila_params']['float']))
$html = '<div style="display: inline-block; float: ' . $context['ila_params']['float'] . ';' . (!empty($style) ? $style : '') . '">' . $html . '</div>';
elseif (!empty($style))
{
if ((!empty($modSettings['ila_download_count']) && $tag['tag'] != 'attachmini') || $tag['tag'] == 'attachurl')
$html = '<div style="display: inline-block; ' . (!empty($style) ? $style : '') . '">' . $html . '</div>';
else
$html = str_replace('<img src="', '<img style="' . $style . '" src="', $html);
}
else
$html = '<div style="display: inline-block;">' . $html . '</div>';
It will be included in the next version of the mod!  Thanks, @rjen!
NOTICE:  My website is back up!

My Free Simple Machines mods on XPtsp.com and Simple Machines Customization Site!
My mods are being uploaded and are available at GitHub as well!