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

Gryzor

I'm not getting that message; the message itself is weird because the attachment is not uploaded till you hit Post, am I wrong?

Otherwise, hitting 'insert' does indeed nothing.

bharat

Somehow if you click on insert attachment and then post message the picture appear in the message.

Gryzor

*IN* the message, or as an attachment?

In my forum, it does the latter...

bharat

Picture is in the message as an attachment.

Gryzor

Not helping :D Is it inline, within the message body, or an attachment?

Maybe it's me who doesn't understand it... maybe a screenshot would help?

skb

Yes, "Insert Attachment" will insert the attachment within the message body.

SMF 2.1.4 / TP 2.2.2

Gryzor


dougiefresh

@Everybody:  There is a new version of PM Attachments uploaded.  It is currently incompatible with version 6.3 and below.

Gryzor

What does 'incompatible' mean in this case? What is going to be lost?

dougiefresh

Quote from: Gryzor on January 20, 2018, 02:58:56 AM
What does 'incompatible' mean in this case?
Right now, you can't install the newest version of PM attachment, then EASILY install versions 6.3 and below onto your forum.  You should wait for the next version, which will take care of the incompatibility....  You also could manually adapt the changes in this mod to get things working; however, we all know how much of a pain THAT is....

Quote from: Gryzor on January 20, 2018, 02:58:56 AM
What is going to be lost?
Nothing.  The new PM attachments mod update has taken care of missing functionality (see this post for update details).  Versions 6.3 and below of this mod simply cannot install over that mod, due to the changes that have been made.

Gryzor

Oh, so if I read this correctly it breakd upwards compatibility, but backwards compatibility is ok. Well, as long as it works fine, I guess that's fine :)

Gryzor

Btw, the mod page lists v6.3 of 08/01/08 as the last one? Is this the one you're referring to in your post from 20/01?

Gryzor

Hello!

Where can I find the newer, >6.3 version?

Thanks!

dougiefresh

@Gryzor:  It hasn't been uploaded yet.

Gryzor

Ohh and here I was F5'ing every day to check :D Thanks for the clarification!

aegersz

I still don't have any automatic embedding of pdf files

I have no error messages and see nothing in the developer tools so i wonder if anything is wrong at my end ?

no big deal but would be nice to have.
The configuration of my Linux VPS (SMF 2.0 with 160+ mods & some assorted manual tweaks) can be found here and notes on my mods can be found here (warning: those links will take you to a drug related forum). My (House) music DJ dedication page is here

RaveN7

Sometimes, after adding a picture as an attachment, the whole text below it becomes a hyperlink. Clicking the text (or the picture) downloads the picture instead of displaying it in a full size :o

How can i fix that?

GL700Wing

While testing Post and PM Inline Attachments V6.3 I discovered a few issues which I resolved as follows:

As per the changes I made to ./Sources/Subs-InlineAttachments.php a separate array is required for messages and PMs so they can be displayed inline.
Find:
// Mark ONLY approved attachments as "don't show" if admin has checked that option:
if (!empty($modSettings['ila_duplicate']) && (!empty($attachment['is_approved']) || !empty($context['ila']['pm_attach'])))
$context['ila']['dont_show'][$msg][$attachment['id']] = true;


Replace with:
// Mark ONLY approved attachments as "don't show" if admin has checked that option:
if (!empty($modSettings['ila_duplicate']) && !empty($attachment['is_approved']))
$context['ila']['dont_show'][$msg][$attachment['id']] = true;

if (!empty($modSettings['ila_duplicate']) && $context['ila']['pm_attach'])
$context['ila']['dont_show'][$attachment['id']] = true;





As per the changes I made to ./Sources/Subs-InlineAttachments.php the code for 'ILA_tag_attachthumb' needs updating.
Find
// AttachThumb => Show thumbnail ONLY, not expandable
function ILA_tag_attachthumb(&$info, &$dim, $has_thumb, $style)
{
$data = &$info;
if (!empty($info['thumbnail']['has_thumb']))
$dim = array('width' => $info['width'], 'height' => $info['height'], 'img' => $info['href']);
else
$dim = array('width' => $info['real_width'], 'height' => $info['real_height']);
return ILA_subfunction($info['id'], $dim['href'], $dim['href'], $info['name'], $style, $has_thumb, false);
}


Replace with:
// AttachThumb => Show thumbnail ONLY, not expandable
function ILA_tag_attachthumb(&$info, &$dim, $has_thumb, $style)
{
$data = &$info;
$image = ($expand = !empty($info['thumbnail']['has_thumb'])) ? $info['thumbnail']['href'] : $info['href'];
if (!empty($info['thumbnail']['has_thumb']))
$dim = array('width' => $info['width'], 'height' => $info['height'], 'img' => $info['href']);
else
$dim = array('width' => $info['real_width'], 'height' => $info['real_height']);
$expand = false;
return ILA_subfunction($info['id'], $info['href'], $image, $info['name'], $style, $has_thumb, $expand);
}





The following code added to install_20x.xml will integrate Post and PM Inline Attachments with the PM Attachments v2.9.  It will also display the option to clear/remove the second and subsequent attachments when composing a new message.

<operation error="ignore">
<search position="replace"><![CDATA[echo '
<script language="JavaScript" type="text/javascript"><!-- // --><![', 'CDATA', '[
var allowed_attachments = ', $context['num_allowed_attachments'], ' - 1;
var current_attachment = 1;

function addAttachment()
{
if (allowed_attachments <= 0)
return alert("', $txt['more_attachments_error'], '");

allowed_attachments = allowed_attachments - 1;
current_attachment = current_attachment + 1;

setOuterHTML(document.getElementById("moreAttachments"), \'<dd class="smalltext"><input type="file" size="38" name="attachment[]" id="attachment\' + current_attachment + \'" class="input_file" /> (<a href="javascript:void(0);" onclick="cleanFileInput(\\\'attachment\' + current_attachment + \'\\\');">', $txt['clean_attach'], '</a>)<\' + \'/dd>\' + (allowed_attachments > 0 ? \'<dd class="smalltext" id="moreAttachments"><a href="javascript:void(0);" onclick="addAttachment(); return false;">(', $txt['more_attachments'], ')<\' + \'/a><\' + \'/dd>\' : \'\'));

return true;
}
// ', ']', ']></script>
</dd>
<dd class="smalltext" id="moreAttachments"><a href="javascript:void(0);" onclick="addAttachment(); return false;">(', $txt['more_attachments'], ')</a></dd>';
]]></search>
<add><![CDATA[echo '
<script type="text/javascript"><!-- // --><![', 'CDATA', '[
var allowed_attachments = ', $context['num_allowed_attachments'], ';
var current_attachment = ', (isset($context['current_attachments']) ? count($context['current_attachments']) : 0) + !empty($modSettings['ila_one_based_numbering']), ';

function addAttachment()
{
allowed_attachments = allowed_attachments - 1;
current_attachment = current_attachment + 1;
if (allowed_attachments <= 0)
return alert("', $txt['more_attachments_error'], '");

var temp = "', $txt['ila_insert'], '";
temp = temp.replace("\%d", current_attachment);
setOuterHTML(document.getElementById("moreAttachments"), \'<dd class="smalltext"><input type="file" size="60" name="attachment[]" id="attachment\' + current_attachment + \'" class="input_file" /> (<a onclick="insertAttachment(\' + current_attachment + \'); return false;">\' + temp + \'</a>) (<a onclick="cleanFileInput(\\\'attachment\' + current_attachment + \'\\\');">', $txt['clean_attach'], '</a>)\' + \'</dd><dd class="smalltext" id="moreAttachments"><a onclick="addAttachment(); return false;">(' . $txt['more_attachments'] . ')<\' + \'/a><\' + \'/dd>\');

return true;
}
// ', ']', ']></script>
</dd>
<dd class="smalltext" id="moreAttachments"><a href="#" onclick="addAttachment(); return false;">(', $txt['more_attachments'], ')</a></dd>';
]]></add>
</operation>



The following code change in install_20x.xml adds a space to each side of 'ila_tag' which allows consecutive inline images to wrap as required when displayed.
Find:
$(smfmod_editor).data(\'sceditor\').insertText(\'[' . $ila_tag . ']\');' : '
replaceText(\'[' . $ila_tag . ']\', document.forms.postmodify.' . $context['post_box_name'] . ');'), '


Replace with:
$(smfmod_editor).data(\'sceditor\').insertText(\' [' . $ila_tag . '] \');' : '
replaceText(\' [' . $ila_tag . '] \', document.forms.postmodify.' . $context['post_box_name'] . ');'), '
Life doesn't have to be perfect to be wonderful ...

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

dougiefresh

Uploaded v6.4 - February 17th, 2018
o Implemented GL700Wing's fixes, as shown here.




@GL700Wing:  I just can't keep up with everything lately....  Thank you for sharing your fixes!  They have been included in this version!

Gryzor

Thanks for the update!

Unfortunately, for me clicking on "Insert Attachment" still does nothing :(

2.0.15...

Advertisement: