Youjoomla Support Forums (
-   YJ Module Engine (
-   -   Intro image replace by article image (

PatG221 02-23-2014 11:06 AM

Intro image replace by article image

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,


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 09: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 05: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,


neo 02-25-2014 09: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 ,


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 09: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 09: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');
$is_image ){
$img JURI::root().'media/k2/items/cache/'.md5("Image".$row->id).'_'.$k2image_size .'.jpg';
$img $images[2][0];

PatG221 02-26-2014 03: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,


PatG221 02-26-2014 03:31 AM

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

        * 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
                function yjme_art_image ($row)
                        $version = new JVersion;
                        if($version->RELEASE > 1.7){       
                                $img_from_params        = json_decode($row->images);
                                        $img_intro                        = $img_from_params->image_intro;
                                        $image_fulltext        = $img_from_params->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;

                                $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
                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,


PatG221 02-26-2014 03: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,


neo 03-04-2014 09: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 05:52 AM.

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