لكن تستلزم هذه المتطلبات في سيرفر الاستضافة ليتم تقليل حجم الصور و تعمل جيداً على منتداك :
- تفعيل دالة allow_url_fopen
- وجود مكتبه ال GD Library
ايضاً يجب ان تعلم ان تقليل حجم الصور يقلل من جودتها .
إذا المتطلبات جميعها متوفرة
فطبق هذه التعديلات
لتركيب خاصية تقليل حجم الصور في موديل المرفقات وايضاً خاصية الصور الرمزية
افتح ملف : includes/functions.class.php
وابحث عن :
CODE
// Visitor Today number
واضف اعلاها هذا الكود :
CODE
function image_quality_reduce($file)
{
global $PowerBB;
$quality = 30;
$file_extension = explode('.', $file);
$ext = strtolower($file_extension[count($file_extension) - 1]);
if(in_array($ext, array('jpg', 'jpeg', 'png', 'gif')))
{
$image = imagecreatefromstring(file_get_contents($file));
$ext == 'jpg' || $ext == 'jpeg' ? imagejpeg($image, $file, $quality) : null;
$ext == 'png' ? imagepng($image, $file, $quality) : null;
$ext == 'gif' ? imagegif($image, $file, $quality) : null;
return $ext;
}
else
{
return false;
}
}
ثم افتح ملف: modules/attachments.module.php
وابحث عن كل (ستجدها مكرره 4 مرات) :
CODE
move_uploaded_file($PowerBB->_FILES['files']['tmp_name'][$x] , $PowerBB->_CONF['info_row']['download_path'] . '/' . $Random);
واضف اسفل كل منها هذا الكود :
CODE
$PowerBB->functions->image_quality_reduce($PowerBB->_CONF['info_row']['download_path']. '/' .$Random);
ثم افتح ملف : modules/usercp.module.php
وابحث عن :
CODE
$copy = move_uploaded_file($PowerBB->_FILES['upload']['tmp_name'],$PowerBB->_CONF['info_row']['download_path'] . '/avatar/' . $filename);
وضع اسفله هذا الكود:
CODE
$PowerBB->functions->image_quality_reduce($PowerBB->_CONF['info_row']['download_path']. '/avatar/' .$filename);
أنتهى .
ملاحظة التطبيق يعمل على الصور الجديدة وليست السابقة
وللتحكم في جودة الصورة غير رقم 30 الموجود في اول كود في الأعلى .