Code: Resize Image In TopicBy: Kirigaya Kazuto
Source: Reference Duelacademy
Demo: [Only admins are allowed to see this image]
APC >> Modules >> HTML & JAVASCRIPT >> Javascript codes management: Tạo 1 JS mới
Title: Resize Image In Topic
Placement: In The Topic
Javascript code:
- Code:
$(window).load(function(){
$('.post img').each(function(){
if($(this).width() > 750 || $(this).height() > 1000) {
var regex = new RegExp(window.location.origin + '\/','i'), target = regex.test($(this).attr('src')) ? '_self' : '_blank';
$(this).css({'max-width':750,'max-height':1000});
$(this).before("<div class='resized_img' style='padding:5px;background:#ddd;max-width:740px;'><a href='/viewimage.forum?u="+$(this).attr('src')+"' alt='Nhấp để xem kích thước gốc' target='"+target+"'>Nhấp để xem kích thước gốc của hình</a></div>");
}
});
});
P/s: Trong đoạn Js trên tìmL
- Code:
if($(this).width() > 750 || $(this).height() > 1000) {
Trong đó: 750 là kích thước chiều rộng tối đa của ảnh
- Code:
$(this).css({'max-width':750,'max-height':1000});
1000 là chiều cao tối đa của ảnh
- Kirigaya Kazuto -
Nguồn: [Only admins are allowed to see this link]