MattW
Well-known member
CorrectPhew. So the only current MetaMirror issue is that sometimes thumbnail generation fails (which is not really MM's fault), so the attachment is not recognized as an image?
CorrectPhew. So the only current MetaMirror issue is that sometimes thumbnail generation fails (which is not really MM's fault), so the attachment is not recognized as an image?
2013-09-10 12:41:36 Rehosted: http://farm6.staticflickr.com/5344/9007433258_906732d0d9_b.jpg For post # 1213313
2013-09-10 12:41:36 Modified post # 1213313 Changed: http://farm6.staticflickr.com/5344/9007433258_906732d0d9_b.jpg => [attach=full]38543[/attach]
Excellent, thanks againYou can disable the cron job once it's finished if you are using instant re-hosting.
Just coming back to this, I've checked the images, and the thumbnails didn't get created correctly, as they are 0 sizeThat looks similar to the issue MattW was having, if the thumbnail generation fails, then the XF attachment system assumes it is not an image. The only thing I can think of there is to re-run rebuilding thumbnails.
I don't THINK it's a MetaMirror issue, just showing up here because of the very large number of thumbnails being generate perhaps stresses the system. And if if that attachment worked before, them MM will not touch the attachment again, so it's something else (failing during rebuild)
z22se@z22se.co.uk [~/public_html/data/attachment-files/2010/07]# ls -al | grep 40346
-rw-r--r-- 1 z22se z22se 129649 Sep 9 06:57 40346_awww.mediajustice.co.uk_images_astrawip_17072010604.jpg
z22se@z22se.co.uk [~/public_html/data/attachment-files/2010/07]# cd thumb/
z22se@z22se.co.uk [~/public_html/data/attachment-files/2010/07/thumb]# ls -al | grep 40346
-rw-r--r-- 1 z22se z22se 0 Sep 9 06:57 40346_awww.mediajustice.co.uk_images_astrawip_17072010604.jpg
I'm mirroring the live site to my ubuntu server at home, and I'll try re-building the thumbnails on there to see if it can be fixed.
class XenForo_Deferred_AttachmentThumb extends XenForo_Deferred_Abstract
{
public function execute(array $deferred, array $data, $targetRunTime, &$status)
{
$data = array_merge(array(
'batch' => 100,
'position' => 0
), $data);
/* @var $attachmentModel XenForo_Model_Attachment */
$attachmentModel = XenForo_Model::create('XenForo_Model_Attachment');
$s = microtime(true);
$dataIds = $attachmentModel->getAttachmentDataIdsInRange($data['position'], $data['batch']);
if (sizeof($dataIds) == 0)
{
return false;
}
foreach ($dataIds AS $dataId)
{
$data['position'] = $dataId;
$dw = XenForo_DataWriter::create('XenForo_DataWriter_AttachmentData', XenForo_DataWriter::ERROR_SILENT);
if ($dw->setExistingData($dataId)
&& $dw->get('width')
&& XenForo_Image_Abstract::canResize($dw->get('width'), $dw->get('height'))
)
{
&& $dw->get('width')
&& XenForo_Image_Abstract::canResize($dw->get('width'), $dw->get('height'))
public static function canResize($width, $height)
{
return (($width * $height) < XenForo_Application::getConfig()->maxImageResizePixelCount);
}
// && $dw->get('width')
if ($imageInfo)
if ($imageInfo && ($imageInfo[2] == IMAGETYPE_GIF || $imageInfo[2] == IMAGETYPE_JPEG || $imageInfo[2] == IMAGETYPE_PNG))
{
$attach = $dw->getMergedData();
$attachFile = $attachmentModel->getAttachmentDataFilePath($attach);
$imageInfo = @getimagesize($attachFile);
if ($imageInfo)
{
$image = XenForo_Image_Abstract::createFromFile($attachFile, $imageInfo[2]);
if ($image)
{
if ($image->thumbnail(XenForo_Application::get('options')->attachmentThumbnailDimensions))
{
ob_start();
$image->output($imageInfo[2]);
$thumbData = ob_get_contents();
ob_end_clean();
}
else
{
// no resize necessary, use the original
$thumbData = file_get_contents($attachFile);
}
$dw->set('thumbnail_width', $image->getWidth());
$dw->set('thumbnail_height', $image->getHeight());
$dw->setExtraData(XenForo_DataWriter_AttachmentData::DATA_THUMB_DATA, $thumbData);
try
{
$dw->save();
}
catch (Exception $e)
{
XenForo_Error::logException($e, false, "Thumb rebuild for #$dataId: ");
}
unset($image);
}
}
}
I've seen mods for other forums that would take any images not hosted on your site, and upload them as an attachment to prevent hotlinking.
Is there a mod for xenforo that does this?
For example if a user uploaded an image to photobucket, I'd like a cron to run that would grab that image, upload it to my forum via attachments and replace the image in the post with the one hosted on my forum.
Thanks
How is hotlink protection enabled in MetaMirror?I have written an add-on that automatically rehosts external images and re-writes the links to post to the local files.
http://xenforo.com/community/resources/metamirror.2117/
It wouldn't have anything to do with hotlink protection, that would be on your server itself.How is hotlink protection enabled in MetaMirror?
It wouldn't have anything to do with hotlink protection, that would be on your server itself.
I want to force SSL through htaccess. Is there anything special I need to do to MetaMirror options after forcing SSL in htaccess?
and just for clarification, I didn't need to change anything. I just ran the "Rebuild Attachment Thumbnails", so if @DRE still has some not working, it's worth giving it a go to see if it fixes your issue as well.Just finished on the live site, and now all images are working correctly
We use essential cookies to make this site work, and optional cookies to enhance your experience.