Youjoomla Support Forums (http://www.youjoomla.com/joomla_support/index.php)
-   YJ Module Engine (http://www.youjoomla.com/joomla_support/forumdisplay.php?f=211)
-   -   Intro image replace by article image (http://www.youjoomla.com/joomla_support/showthread.php?t=12298)

PatG221 02-23-2014 12:06 PM

Intro image replace by article image
 
Hello,

I am using template "Quality SOund" as is, and I have a problem with module YJ Module Engine.

I am using Joomla content, and not K2.

I indicated an intro image to be visible, so far so good, it works.

BUT as soon as I insert an image in the article, it is this one (and NOT the intro image) that appears in the module.

Could you kindly let me know where I need to go to correct this?

With many thanks,

Pat

Are you sure your are posting in product assigned forum?: Yes

What is your CMS version?: Joomla 2.5

MySQL Version: 5.x

PHP version: 5.x

Link to installation: Dominique Rey, compositrice

Have you edited any files? If yes tell us which ones.: No

Is this personal or client website?: Personal

arefund 02-24-2014 10:34 AM

Hello PatG221.

The engine is checking if image exist inside the article. If the image is there it will take the image. Also the intro image is the image from your article.

As you can see here this is the only image inside your article and that image is the one that engine is pulling out.

Dominique Rey

Thank you.

PatG221 02-24-2014 06:23 PM

Thank you for your reply.

I have specified a different intro image for this article (not the picture in the article text). This is possible, in much the same way as in k2.

I would like the engine to pick up the intro image only, irrelevant of the fact that there is an image in the text of the article or not.

Could you let me know where to edit the code for this?

Wth many thanks in advance,

Pat

neo 02-25-2014 10:07 AM

image in the article has the priority over the intro image

see mod_yjme/yjme/k2functions.php function k2_yjme_art_image

you might want to change that preg_match_all to look for specific class ,


example



PHP Code:

preg_match_all("#\<img class=\"introimage\"(.*)src\=\"(.*)\"#Ui" 

so if you have an image with class name introimage in article than article image wil take over otherwise the assigned intro image will be displayed

neo 02-25-2014 10:09 AM

looking at the code now I should have done reversed check , check if image is assigned , if not use article image

neo 02-25-2014 10:15 AM

Try this one, change that complete function to this




PHP Code:



function k2_yjme_art_image ($row)
{    
    
$is_image JFile::exists(JPATH_SITE.DIRECTORY_SEPARATOR.'media'.DIRECTORY_SEPARATOR.'k2'.DIRECTORY_SEPARATOR.'items'.DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR.md5("Image".$row->id).'_'.$k2image_size .'.jpg');
    
    if( 
$is_image ){
        
        
$img JURI::root().'media/k2/items/cache/'.md5("Image".$row->id).'_'.$k2image_size .'.jpg';
        return 
$img;
        
    }else{
        
        if(
preg_match_all("#\<img(.*)src\=\"(.*)\"#Ui"$row->introtext$images)){
            
            
$img $images[2][0];
            return 
$img;
        }
    }
    



PatG221 02-26-2014 04:22 AM

Thank you very much for this, Neo.

But this is for K2... would you have the same thiong for Joomla content?

With huge anticipated thanks,

Pat

PatG221 02-26-2014 04:31 AM

Neo, I just saw the code in file jomfunctions.php, but it does not work: here it is
Code:

        * Smart Image detection inside article. Searches in intro text and if not found, in full article text from Joomla 2.5 intro image and full image from params. Image within article has priority.
        *
        * @param object $row
        * @return string - image path
        */
        if(!function_exists('yjme_art_image'))
        {       
                function yjme_art_image ($row)
                {
                       
                        $version = new JVersion;
                        if($version->RELEASE > 1.7){       
                               
                                $img_from_params        = json_decode($row->images);
                                if(isset($img_from_params->image_intro)){
                                        $img_intro                        = $img_from_params->image_intro;
                                }else{
                                        $img_intro='';
                                }
                                if(isset($img_from_params->image_fulltext)){
                                        $image_fulltext        = $img_from_params->image_fulltext;
                                }else{
                                        $image_fulltext='';
                                }
                                $img                              = yjme_search_image ( $row->introtext );
                                $img_full                        = yjme_search_image ( $row->fulltext );
                                if( $img ) return $img;
                                if( $img_full ) return $img_full;
                                if( $img_intro ) return $img_intro;
                                if( $image_fulltext ) return $image_fulltext;

                        }else{
                               
                                $img = yjme_search_image ( $row->introtext );
                                if( $img ) return $img;
                                               
                                $img = yjme_search_image ( $row->fulltext );
                                return $img;                       
                               
                        }
                }
        }
                /**
                * Searches for all images inside a text and returns the first one found
                *
                * @param string $text
                * @return string
                */
        if(!function_exists('yjme_search_image'))
        {       
                function yjme_search_image ( $text )
                {               
                        preg_match_all("#\<img(.*)src\=\"(.*)\"#Ui", $text, $mathes);               
                        return isset($mathes[2][0]) ? $mathes[2][0] : '';                       
                }
        }


Can you figure out why?

With many thanks again,

Pat

PatG221 02-26-2014 04:46 AM

OK, figured it out: the code does give text image priority - I hacked it in order to treat only the image defined as $img_intro, and it works.

Many thanks for your help, and for pointing me in the right direction!

With best regards,

Pat

neo 03-04-2014 10:29 AM

ok bud sorry for not following this post I had a rough coding past 2 days .


All times are GMT -4. The time now is 03:24 AM.

Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.