Hi Mick, thanks for this
But, what can i do when the path of a changed link is wrong?
I need www.xxxx.de/xenforo/data/meta...... and there is www.xxxx.de/data in the post.
Thanks for any idea
If you have some code sample for how to add an attachment (either from a local file or a string) to a post, then I could roll it in pretty quick.
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;
}
If you have a CDN set up and reference via something like:
$config['externalDataUrl'] = 'http://example.com/data';
Then MetaMirror will now detect this, and handle renaming the URL correctly.
It will also automatically add the externalDataUrl string to the list of ignore strings if it is absolute. So you won't get in a loop of re-hosting your CDN files
Hi Mick, thanks for this
But, what can i do when the path of a changed link is wrong?
I need www.xxxx.de/xenforo/data/meta...... and there is www.xxxx.de/data in the post.
Thanks for any idea
Humm... Another option could be to attach images with larger dimensions than the default thumbnail dimensions. Something like images larger than 100x100.One problem with using attachments is that a lot of the time people will cut and paste in a section of a web page that has a lot of tiny images, like arrows and buttons, smilies, facebook profile images, and even blank spacers. So if they are all rehosted as attachments you are going to get a lot of duplicates of tiny meaningless images in your attachment manager.
Example 645 byte image.
A possible solution would be to only use attachments for files over a certain size, so only useful/interesting images get made into attachments.
One problem with using attachments is that a lot of the time people will cut and paste in a section of a web page that has a lot of tiny images, like arrows and buttons, smilies, facebook profile images, and even blank spacers. So if they are all rehosted as attachments you are going to get a lot of duplicates of tiny meaningless images in your attachment manager.
I mean they would be meaningless in the attachments manager. Just a lot of clutter - so it's not that useful to have them as attachments. I'd suggest maybe (optionally) using the direct file caching for small images and converting to attachments for the large images. Although you'd still get the issue of the small files being left behind if a post is deleted.Hi Mike,
There's really no such thing as a meaningless image. For example one small smilie can change the entire tone of a post.
Curious, how you set up the path or folder the images are stored in? With Xenforo, attachments folders contains a maximum of 1000 attachments, this is an important feature because you don't want a folder with tens of thousands of files in it.
I mean they would be meaningless in the attachments manager. Just a lot of clutter - so it's not that useful to have them as attachments. I'd suggest maybe (optionally) using the direct file caching for small images and converting to attachments for the large images. Although you'd still get the issue of the small files being left behind if a post is deleted.
Do you know if there is some kind of reference counting for attachments, to determine if they can be deleted?
It's just a single folder under data/ right now. I guess I could add an option to split it up, maybe based on sanitized remote host names. Personally I like it all in one large folder, but that's probably because I'm just a small forum guy (there were under 2000 images that needed rehosting). What are the problems with lots of images in a single folder?
[ATTACH]52512[/ATTACH]
I meant the Attachment Browser, in the ACP under ApplicationsI'm sorry, I don't know what you mean by attachment manager. Is this something your add-on provides?
The biggest downside to having tens of thousands of files in a single folder is that if you click a folder that contains the files using a program like Dreamweaver or Webmin, it takes a very long time before you can see all the files.
Just a note - this is still open to exploits even with the exif_imagetype fix. It's quite easy to embed php code inside an image that would pass that check.
Either .php (and any other php-enabled extensions, such as .html) needs to be in the ignore list by default or users need to disable php execution in /data
if ($curlErrorCode === 0) {
$info = curl_getinfo ( $curl_array [$i] );
$ext = getExtention ( $info ['content_type'] );
if ($info ['content_type'] !== null) {
$temp = "temp/img" . md5 ( mt_rand () ) . $ext;
touch ( $temp );
$imageContent = curl_multi_getcontent ( $curl_array [$i] );
file_put_contents ( $temp, $imageContent );
if ($maxHeight == 0 || $maxWidth == 0) {
$res [] = $temp;
} else {
$size = getimagesize ( $temp );
if ($size [0] >= $maxHeight && $size [0] >= $maxWidth) {
$res [] = $temp;
} else {
unlink ( $temp );
}
}
}
}
I meant the Attachment Browser, in the ACP under Applications
We use essential cookies to make this site work, and optional cookies to enhance your experience.