I have over 325,000 attachments in my forum and I have never used the Attachment Manager in the Admin CP. I don't see any need for that application.
Yeah, me neither. But someone metioned being able to see the rehosted files there as a benefit.
I have over 325,000 attachments in my forum and I have never used the Attachment Manager in the Admin CP. I don't see any need for that application.
That would be me, as you can use it to sort, largest attachments, latest, by date range and filter attachments by user too. You don't even have to go to post to view attachment. Useful and built into xenforo, whether you use it or not.
Another thing to consider, Mike. When your cron runs I assume you are using SELECT and LIKE '%[I M G]%'. If so are you limiting the number of posts or searching all the messages?
SELECT * FROM ".self::$table_name."
INNER JOIN xf_thread ON (xf_thread.thread_id = xf_post.thread_id)
WHERE ".self::$column_name." LIKE '%[/IMG]%'
AND MetaMirror_Processed != ".MMR_MAGIC."
".$excluder."
LIMIT 0, ".self::$max_posts
$excluder = isset (self::$exclude_forums[0]) ? ("AND node_id NOT IN (".$db->quote(self::$exclude_forums).")"):"";
Any thoughts on adding a path setting so we can tell it to add our cdn in the url? Also the ability to have it check again and update the links with that setting would be nice.
Great Job on this Mike. I have so many old posts with dead pics. You have made a pretty awesome mod here on so many levels.
As well as performing a check to see if the data is an image (with exif_imagetype), I now also strip off any file extension that is not in
('jpg','jpeg','png','gif','bmp','ico')
Safe extensions are added back onto hashed file names generated from files with parameters, so other programs can still see them as images.
Well, I have the cdn settings but the app says that the images will be set to the url of my site without the cdn settings. So my cdn is http://cdn.mysite.com/images and the app is setting them as http://mysite.com/images. I saw you mention it would read that in one of the updates. Possibly it doesn't if it's already run before that update?
I haven't had time to look into the code but sniffing on the importer files (i love to reading importers because you can learn so much!) I took the code that imports attachments and came up with this method (not my code, I just took it and removed unnecessary lines):
Watch out for:
- $this->_getDb(): I don't know where you'll use this code (probably a model) so I just left it unmodified. This code is from a model so the class where I took it extends XenForo_Model. If you use it somewhere else, make sure to use a proper database object.
PHP:public function importPostAttachment($fileName, $tempFile, $userId, $postId, $date, array $attach = array()) { $upload = new XenForo_Upload($fileName, $tempFile); try { $dataExtra = array('upload_date' => $date, 'attach_count' => 1); $dataId = $this->getModelFromCache('XenForo_Model_Attachment')->insertUploadedAttachmentData($upload, $userId, $dataExtra); } catch (XenForo_Exception $e) { return false; } $dw = XenForo_DataWriter::create('XenForo_DataWriter_Attachment'); //$dw->setImportMode(true); $dw->bulkSet(array( 'data_id' => $dataId, 'content_type' => 'post', 'content_id' => $postId, 'attach_date' => $date, 'unassociated' => 0 )); $dw->bulkSet($attach); $dw->save(); $newAttachmentId = $dw->get('attachment_id'); $this->_getDb()->query(' UPDATE xf_post SET attach_count = IF(attach_count < 65535, attach_count + 1, 65535) WHERE post_id = ? ', $postId); return $newAttachmentId; }
Possible to limit the size?
For example some one post an image of 4mb, can I setup that only max 1mb files allowed?
Both ideas are quite alright I guessRather than limiting the size, an option to scale to a maximum size would be better. For example scale images larger than 1600px to 1600px width.
- Added option to use attachments insteda of file system
- Added option to limit file size
- Added option to add info to altered posts
See attached image
Thank you!!!!!Mick West updated MetaMirror with a new update entry:
Optionally use attachments instead of filesystem, limit size of files
Read the rest of this update entry...
very nice update. do you think we could have an option to put it in moderator bar instead of navigation bar please![]()
We use essential cookies to make this site work, and optional cookies to enhance your experience.