-
-
Notifications
You must be signed in to change notification settings - Fork 408
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Editor Paste / Drag-drop Image Handler #4359
Open
effone
wants to merge
16
commits into
mybb:feature
Choose a base branch
from
effone:paste-dragdrop-handler
base: feature
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
256edc8
Include editor event handler addon
effone 348001a
Create settings
effone 17bae90
Simplify codebuttons template, var naming standard, move templated / …
effone 74d32d3
Add paste / drag-drop event handler
effone 7119e63
Adhere settings
effone 6c827a5
Backend upload handler
effone bc8b4e2
Syntax error correction: 5.3 compatibility
effone 9127839
Postembed image upload directory and setting
effone c6a3e62
CHMOD checks
effone 7293031
Path correction
effone 07d8609
Typo
effone d8584e1
Create task to cleanup orphan post embed images
effone fa36856
Restore Editor to global scope
effone e93e579
Include missing functions script
effone 586101f
Rename editor bridge to avoid upgrade conflicts
effone d6709f6
Relative path requirement in description
effone File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
/** | ||
* MyBB 1.8 | ||
* Copyright 2021 MyBB Group, All Rights Reserved | ||
* | ||
* Website: http://www.mybb.com | ||
* License: http://www.mybb.com/about/license | ||
* | ||
*/ | ||
|
||
function task_postembedscleanup($task) | ||
{ | ||
global $mybb, $db, $lang, $plugins; | ||
|
||
$dir = trim($mybb->settings['postembedpath'], './'); | ||
$files = glob(MYBB_ROOT."{$dir}/*.{jpg,jpeg,png}", GLOB_BRACE); | ||
|
||
if(is_object($plugins)) | ||
{ | ||
$args = array( | ||
'task' => &$task, | ||
'files' => $files, | ||
); | ||
$plugins->run_hooks('task_postembedscleanup', $args); | ||
} | ||
|
||
foreach ($files as $file) | ||
{ | ||
$link = str_replace(MYBB_ROOT, $mybb->settings['bburl'] . '/', $file); | ||
$query = $db->simple_select("posts", "COUNT(DISTINCT pid) AS postcount", "message like '%[img%]{$link}[/img]%'"); | ||
if (!$db->fetch_field($query, 'postcount')) | ||
{ | ||
@unlink($file); | ||
} | ||
} | ||
add_task_log($task, $lang->task_postembedscleanup_ran); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't this be problematic for large amount of files? Will the task always fulfill properly regardless of the amount of images? I'm a little surprised by the lack of a database table to control uploaded images, which limits the addition of some ACP interface to manage these unless, for example, being somehow merged with the current attachments tools later on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The concern is correct at I have not done a performance benchmarking.
Am open to accept any suggestion to improve this. I also felt the necessity of a dedicated table for upload entries. Didn't follow that way as that can be considered as
Big Change
leading to rejection of this PR.