زمان کنونی: ۱۸-۸-۱۴۰۵, ۰۳:۰۱ عصر درود مهمان گرامی! (ورود — ثبت نام)


ارسال پاسخ 
 
امتیاز موضوع:
  • 0 رأی - میانگین امتیازات: 0
  • 1
  • 2
  • 3
  • 4
  • 5
درخواست راهنمایی برای ایجاد فیلدی در ماژول
۲۲-۱۲-۱۳۹۳, ۰۱:۱۹ صبح
ارسال: #9
RE: درخواست راهنمایی برای ایجاد فیلدی در ماژول
الان همین متد تابع getThumbnails که فرمودید توی فایل helper به شکل زیر نوشته شده و خودش پر از if های تو در تو هستش

نمی دونم به چه شکلی و کجا این شرط if رو به شکلی که گفتید اضافه کنم

ممنون میشم با توجه به کد های زیر کمک کنید که به چه شکل باید اضافه بشه


public static function getThumbnails(&$text, $mode, $thumbnail_width, $thumbnail_height, $isOverride = false, $clearImage = false){
      
      
$resizePath = JPATH_ROOT.DS."images/resized/modules/mod_jvnews/".substr($mode, 0, 5)."_{$thumbnail_width}_{$thumbnail_height}/";
        
$link       = JURI::base()."images/resized/modules/mod_jvnews/".substr($mode, 0, 5)."_{$thumbnail_width}_{$thumbnail_height}/";
        
$regex      = '/<img.*src=[\'\"]([^\'^\"]*)?[\'\"].*\/>/i';
        
$thumnails  = array();
        
        if(!
JFolder::exists($resizePath)){
            if(!
JFolder::create($resizePath)) return;
            
$index = "<html><body></body></html>";
            if(!
JFile::write($resizePath.DS.'index.html',$index)) return;
        }
        
        if(
preg_match('/<img\b[^>]*\/>/i', $text)){            
           
preg_match_all($regex, $text, $matches); 
                        
           if(
count($matches)){
                foreach(
$matches[1] as $match){
                    
$imagename  = self::getFileName($match); 
                    
$fileNameParts = explode('.',$imagename);                        
                    
$fileExtension = array_pop($fileNameParts);  
                    
$fileExtension = current(explode('?', substr($fileExtension, 0, 3)));
                    
$imagename     = current($fileNameParts).'.'.$fileExtension;

                    if(!
JFile::exists($resizePath.$imagename)){
                        
$images        = (preg_match('/http:\/\//', $match) || preg_match('/https:\/\//', $match)) ? $match : JPATH_SITE.'/'.$match;
                        
$thumb         = new GdThumb(str_replace('&amp;', '&', $images));
                        
                        switch(
$mode){
                            case 
'resize':
                                
$thumb->resize($thumbnail_width, $thumbnail_height);
                            break;
                            case 
'adaptiveresize':
                                
$thumb->adaptiveResize($thumbnail_width, $thumbnail_height);
                            break;
                            case 
'crop':
                                
$thumb->crop(0, 0, $thumbnail_width, $thumbnail_height);
                            break;
                            case 
'cropfromcenter':
                                
$thumb->cropFromCenter($thumbnail_width, $thumbnail_height);
                            break;                            
                        }
                        
                        
$thumb->save($resizePath.$imagename, $fileExtension);              
                    }
                    
                    if(
$isOverride && !$clearImage){
                        
$text = str_replace($match,$link.$imagename,$text);         
                    }else{
                        
$text = $text;
                    }
                                
                    
$thumnails[] = $link.$imagename;
                }                    
           }
        }
        if(
$clearImage){
            
$text = preg_replace($regex, '', $text);
        }
        
        return 
$thumnails;
    } 



ممنون
امضاء mrt69
دیدن لینک ها برای شما امکان پذیر نیست. لطفا ثبت نام کنید یا وارد حساب خود شوید تا بتوانید لینک ها را ببینید.
یافتن تمامی ارسال‌های این کاربر
نقل قول این ارسال در یک پاسخ بازگشت به بالا
ارسال پاسخ 


پیام‌های داخل این موضوع
RE: درخواست راهنمایی برای ایجاد فیلدی در ماژول - mrt69 - ۲۲-۱۲-۱۳۹۳ ۰۱:۱۹ صبح

پرش به انجمن:


کاربرانِ درحال بازدید از این موضوع: 2 مهمان