مرجع پارسی MyBB
[آموزش] تغییر سایز عکس با استفاده از جاوا - نسخه‌ی قابل چاپ

+- مرجع پارسی MyBB (https://community.mybbiran.com)
+-- انجمن: نسخه MyBB 1.8 (https://community.mybbiran.com/forum-149.html)
+--- انجمن: آموزش ها (https://community.mybbiran.com/forum-151.html)
+---- انجمن: سایر آموزش‌ها (https://community.mybbiran.com/forum-158.html)
+---- موضوع: [آموزش] تغییر سایز عکس با استفاده از جاوا (/thread-18086.html)



[آموزش] تغییر سایز عکس با استفاده از جاوا - saeed_same - ۱۳۹۴/۳/۳۱

کد زیر را در notepad++ کپی و با نام resizer.js ذخیره کنید

کد:
// jQuery.naturalWidth / jQuery.naturalHeight plugin for (already-loaded) images

// Triple-licensed: Public Domain, MIT and WTFPL license - share and enjoy!

(function($) {
 function img(url) {
   var i = new Image;
   i.src = url;
   return i;
 }

 if ('naturalWidth' in (new Image)) {
   $.fn.naturalWidth  = function() { return this[0].naturalWidth; };
   $.fn.naturalHeight = function() { return this[0].naturalHeight; };
   return;
 }
 $.fn.naturalWidth  = function() { return img(this[0].src).width; };
 $.fn.naturalHeight = function() { return img(this[0].src).height; };
})(jQuery);

$(document).ready(function() {
   function imageLoaded() {
       var resizelang = 'Click on this image to display the full size version.';
       var resizedsize =  $(this).width();
       var origsize = $(this).naturalWidth();
       if (origsize!=resizedsize) {
           $(this).wrap('<div></div>').attr('title', resizelang).on('click', function() {
               if ($(this).is('[title]')) {
                   $(this).removeAttr('title');
               }
               else {
                   $(this).attr('title', resizelang);
               }
               var parentheight = $(this).parent().height();
               if (!$(this).hasClass('resize')) {
                   $(this).addClass('resize').parent().css('height', parentheight+'px');
               }
               else
               {
                   $(this).removeAttr('class').parent().css('height', '');
               }
           });
       }
   }
   $('.scaleimages img').each(function() {
       if( this.complete ) {
           imageLoaded.call( this );
       } else {
           $(this).one('load', imageLoaded);
       }
   });
});

و در مسیر root/jscripts/ آپلود کنید

به کنترل پنل ادمین انجمن خود رفته و فایل headerinclude را باز کنید
کد زیر را یافته


کد:
<script type="text/javascript" src="{$mybb->asset_url}/jscripts/general.js?ver=1800"></script>

و در زیر آن کد زیر را قرار دهید


کد:
<script type="text/javascript" src="{$mybb->asset_url}/jscripts/resizer.js"></script>

به پوسته قالب خود رفته و فایل global.css را در حالت ویرایش پیشرفته قرار دهید

کد:
.resize {
   max-width: none !important;
   position: absolute !important;
   z-index: 20 !important;
}

لینک مرجع
ترجمه : انجمن پارسیان دانلود


RE: تغییر سایز عکس با استفاده از جاوا - firstboy000 - ۱۳۹۴/۳/۳۱

درود، لینک مرجع آموزش و یک نمونه شات به همراه توضیح کوتاهی که کارش چیه دقیقا و در چه مواقع عمل میکنه رو اضافه کنید، با سپاس، موفق باشید


RE: تغییر سایز عکس با استفاده از جاوا - saeed_same - ۱۳۹۴/۳/۳۱

توضیح خاصی نداره فقط عکسهایی که با سایز بزرگ کپی میشن رو به سایز کوچیکتر تبدیل مینه تا باعث بارگذاری زودتر عکس و سرعت بالا انجمن بشه


RE: تغییر سایز عکس با استفاده از جاوا - NickelBack - ۱۳۹۴/۴/۱

لطفا نمونه قرار دهید آیا مثل 1.6 هست که کاربر بتونه تصویر رو خودش بزرگ کنه؟