Simple Machines Community Forum

Customizing SMF => Modifications and Packages => Mod Requests => Topic started by: [chrisB] on March 11, 2025, 09:50:08 PM

Title: Question: Attachments for quick reply
Post by: [chrisB] on March 11, 2025, 09:50:08 PM
Does anyone know how to add the ability to upload attachments in the 'quick reply'?

If possible, with the "Other options" too.

(https://i.imgur.com/HkBdAdE.png)
This would make a great trick if anyone knows who it can be achieved.  ;) 
Title: Re: Question: Attachments for quick reply
Post by: [chrisB] on March 12, 2025, 12:25:04 PM
Does it have to be a mod?

// The non-JavaScript UI.
echo '
<div id="postAttachment">
<div class="padding">
<div>
<strong>', $txt['attachments'], '</strong>:';

if ($context['can_post_attachment'])
echo '
<input type="file" multiple="multiple" name="attachment[]" id="attachment1">
<a href="javascript:void(0);" onclick="cleanFileInput(\'attachment1\');">(', $txt['clean_attach'], ')</a>';

if (!empty($modSettings['attachmentSizeLimit']))
echo '
<input type="hidden" name="MAX_FILE_SIZE" value="' . $modSettings['attachmentSizeLimit'] * 1024 . '">';

echo '
</div>';

if (!empty($context['attachment_restrictions']))
echo '
<div class="smalltext">', $txt['attach_restrictions'], ' ', implode(', ', $context['attachment_restrictions']), '</div>';

echo '
<div class="smalltext">
<input type="hidden" name="attach_del[]" value="0">
', $txt['uncheck_unwatchd_attach'], '
</div>
</div>
<div class="attachments">';

// If this post already has attachments on it - give information about them.
if (!empty($context['current_attachments']))
{
foreach ($context['current_attachments'] as $attachment)
{
echo '
<div class="attached">
<input type="checkbox" id="attachment_', $attachment['attachID'], '" name="attach_del[]" value="', $attachment['attachID'], '"', empty($attachment['unchecked']) ? ' checked' : '', '>';

if (!empty($modSettings['attachmentShowImages']))
{
if (strpos($attachment['mime_type'], 'image') === 0)
$src = $scripturl . '?action=dlattach;attach=' . (!empty($attachment['thumb']) ? $attachment['thumb'] : $attachment['attachID']) . ';preview;image';
else
$src = $settings['images_url'] . '/generic_attach.png';

echo '
<div class="attachments_top">
<img src="', $src, '" alt="" loading="lazy" class="atc_img">
</div>';
}

echo '
<div class="attachments_bot">
<span class="name">' . $attachment['name'] . '</span>', (empty($attachment['approved']) ? '
<br>(' . $txt['awaiting_approval'] . ')' : ''), '
<br>', $attachment['size'] < 1024000 ? round($attachment['size'] / 1024, 2) . ' ' . $txt['kilobyte'] : round($attachment['size'] / 1024 / 1024, 2) . ' ' . $txt['megabyte'], '
</div>
</div>';
}
}

echo '
</div>
</div>';

if (!empty($context['files_in_session_warning']))
echo '
<div class="smalltext"><em>', $context['files_in_session_warning'], '</em></div>';

// Is the user allowed to post any additional ones? If so give them the boxes to do it!
if ($context['can_post_attachment'])
{
// Print dropzone UI.
echo '
<div id="attachment_upload">
<div id="drop_zone_ui" class="centertext">
<div class="attach_drop_zone_label">
', $context['num_allowed_attachments'] <= count($context['current_attachments']) ? $txt['attach_limit_nag'] : $txt['attach_drop_zone'], '
</div>
</div>
<div class="files" id="attachment_previews">
<div id="au-template">
<div class="attachment_preview_wrapper">
<div class="attach-ui roundframe">
<a data-dz-remove class="main_icons delete floatright cancel"></a>
<div class="attached_BBC_width_height">
<div class="attached_BBC_width">
<label for="attached_BBC_width">', $txt['attached_insert_width'], '</label>
<input type="number" name="attached_BBC_width" min="0" value="">
</div>
<div class="attached_BBC_height">
<label for="attached_BBC_height">', $txt['attached_insert_height'], '</label>
<input type="number" name="attached_BBC_height" min="0" value="">
</div>
</div>
</div>
<div class="attach-preview">
<img data-dz-thumbnail />
</div>
<div class="attachment_info">
<span class="name" data-dz-name></span>
<span class="error" data-dz-errormessage></span>
<span class="size" data-dz-size></span>
<span class="message" data-dz-message></span>
<div class="progress_bar" role="progressBar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0">
<div class="bar"></div>
</div>
</div><!-- .attachment_info -->
</div>
</div><!-- #au-template -->
<div class="attachment_spacer">
<div class="fallback">
<input type="file" multiple="multiple" name="attachment[]" id="attachment1" class="fallback"> (<a href="javascript:void(0);" onclick="cleanFileInput(\'attachment1\');">', $txt['clean_attach'], '</a>)';

if (!empty($modSettings['attachmentSizeLimit']))
echo '
<input type="hidden" name="MAX_FILE_SIZE" value="' . $modSettings['attachmentSizeLimit'] * 1024 . '">';

echo '
</div><!-- .fallback -->
</div>
</div><!-- #attachment_previews -->
</div>
<div id="max_files_progress" class="max_files_progress progress_bar" role="progressBar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0">
<div class="bar"></div>
<div id="max_files_progress_text"></div>
</div>';
}

echo '
</div>';
}

// If the admin has enabled the hiding of the additional options - show a link and image for it.
if (!empty($modSettings['additional_options_collapsable']))
echo '
<div id="post_additional_options_header">
<strong><a href="#" id="postMoreExpandLink"> ', $txt['post_additionalopt'], '</a></strong>
</div>';

echo '
<div id="post_additional_options">';

// Display the checkboxes for all the standard options - if they are available to the user!
echo '
<div id="post_settings" class="smalltext">
<ul class="post_options">
', $context['can_notify'] ? '<li><input type="hidden" name="notify" value="0"><label for="check_notify"><input type="checkbox" name="notify" id="check_notify"' . ($context['notify'] || !empty($options['auto_notify']) || $context['auto_notify'] ? ' checked' : '') . ' value="1"> ' . $txt['notify_replies'] . '</label></li>' : '', '
', $context['can_lock'] ? '<li><input type="hidden" name="already_locked" value="' . $context['already_locked'] . '"><input type="hidden" name="lock" value="0"><label for="check_lock"><input type="checkbox" name="lock" id="check_lock"' . ($context['locked'] ? ' checked' : '') . ' value="1"> ' . $txt['lock_topic'] . '</label></li>' : '', '
<li><label for="check_back"><input type="checkbox" name="goback" id="check_back"' . ($context['back_to_topic'] || !empty($options['return_to_post']) ? ' checked' : '') . ' value="1"> ' . $txt['back_to_topic'] . '</label></li>
', $context['can_sticky'] ? '<li><input type="hidden" name="already_sticky" value="' . $context['already_sticky'] . '"><input type="hidden" name="sticky" value="0"><label for="check_sticky"><input type="checkbox" name="sticky" id="check_sticky"' . ($context['sticky'] ? ' checked' : '') . ' value="1"> ' . $txt['sticky_after_posting'] . '</label></li>' : '', '
<li><label for="check_smileys"><input type="checkbox" name="ns" id="check_smileys"', $context['use_smileys'] ? '' : ' checked', ' value="NS"> ', $txt['dont_use_smileys'], '</label></li>', '
', $context['can_move'] ? '<li><input type="hidden" name="move" value="0"><label for="check_move"><input type="checkbox" name="move" id="check_move" value="1"' . (!empty($context['move']) ? ' checked" ' : '') . '> ' . $txt['move_after_posting'] . '</label></li>' : '', '
', $context['can_announce'] && $context['is_first_post'] ? '<li><label for="check_announce"><input type="checkbox" name="announce_topic" id="check_announce" value="1"' . (!empty($context['announce']) ? ' checked' : '') . '> ' . $txt['announce_topic'] . '</label></li>' : '', '
', $context['show_approval'] ? '<li><label for="approve"><input type="checkbox" name="approve" id="approve" value="2"' . ($context['show_approval'] === 2 ? ' checked' : '') . '> ' . $txt['approve_this_post'] . '</label></li>' : '', '
</ul>
</div><!-- #post_settings -->';

echo '
</div><!-- #post_additional_options -->';

This is the code I believe handles the attachments, but I don't have enough knowledge to know if it can be implemented as an edit to the Class-QuickReply.php.
Title: Re: Question: Attachments for quick reply
Post by: GL700Wing on March 12, 2025, 03:52:29 PM
@[chrisB]  Have you tried using the Quick Reply Attachments Button (https://custom.simplemachines.org/index.php?mod=4313) mod?
Title: Re: Question: Attachments for quick reply
Post by: [chrisB] on March 12, 2025, 08:08:17 PM
Quote from: GL700Wing on March 12, 2025, 03:52:29 PM@[chrisB]  Have you tried using the Quick Reply Attachments Button (https://custom.simplemachines.org/index.php?mod=4313) mod?

Yes, it just seemed to redirect to the reply page.

Thanks for pointing out though.