test
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • hiepdang Friend
    #189782

    Im working on my localhost, so it hard to say, but can i plain here. I’m working on Ja-nex, and looking at Ja News Featured modules, set to get featured articles from all category. It all work fine accept one thing.
    When i set thumbnail image, Ja News Featured will get that thumbnail image, instead of full-text images.

    So, i look in some functions, and get this function will get image to display:
    [PHP]
    function parseImage($row)
    {
    //check to see if there is an intro image or fulltext image first
    $images = “”;
    if (isset($row->images)) {
    $images = json_decode($row->images);
    }
    if((isset($images->image_fulltext) and !empty($images->image_fulltext)) || (isset($images->image_intro) and !empty($images->image_intro))){
    $image = (isset($images->image_intro) and !empty($images->image_intro))?$images->image_intro:((isset($images->image_fulltext) and !empty($images->image_fulltext))?$images->image_fulltext:””);
    }
    else {
    $regex = ‘/<img.+srcs*=s*”([^”]*)”[^>]*>/’;
    $text = ”;
    $text .= (isset($row->fulltext))?$row->fulltext:”;
    $text .= (isset($row->introtext))?$row->introtext:”;
    preg_match($regex, $text, $matches);
    $images = (count($matches)) ? $matches : array();
    $image = count($images) > 1 ? $images[1] : ”;
    }
    return $image;
    }[/PHP]

    Is it right? So, it would be nice if some one help me to get image in Ja News Featured only get from images->image_fulltext, not the first image, not image_intro

    Thank you so much.
    :-[

    Ninja Lead Moderator
    #502463

    Yes, if you want to get only image_fulltext in Ja News Featured module, you can change this way

    From


    function parseImage($row)
    {
    //check to see if there is an intro image or fulltext image first
    $images = "";
    if (isset($row->images)) {
    $images = json_decode($row->images);
    }
    if((isset($images->image_fulltext) and !empty($images->image_fulltext)) || (isset($images->image_intro) and !empty($images->image_intro))){
    $image = (isset($images->image_intro) and !empty($images->image_intro))?$images->image_intro:((isset($images->image_fulltext) and !empty($images->image_fulltext))?$images->image_fulltext:"");
    }
    else {
    $regex = '/<img.+srcs*=s*"([^"]*)"[^>]*>/';
    $text = '';
    $text .= (isset($row->fulltext))?$row->fulltext:'';
    $text .= (isset($row->introtext))?$row->introtext:'';
    preg_match($regex, $text, $matches);
    $images = (count($matches)) ? $matches : array();
    $image = count($images) > 1 ? $images[1] : '';
    }
    return $image;
    }

    Change to


    function parseImage($row)
    {
    //check to see if there is an intro image or fulltext image first
    $images = "";
    if (isset($row->images)) {
    $images = json_decode($row->images);
    }
    if(isset($images->image_fulltext) and !empty($images->image_fulltext)){
    $image = (isset($images->image_fulltext) and !empty($images->image_fulltext))?$images->image_fulltext:"";
    }
    else {
    $regex = '/<img.+srcs*=s*"([^"]*)"[^>]*>/';
    $text = '';
    $text .= (isset($row->fulltext))?$row->fulltext:'';
    preg_match($regex, $text, $matches);
    $images = (count($matches)) ? $matches : array();
    $image = count($images) > 1 ? $images[1] : '';
    }
    return $image;
    }

    But you also need to change all jaimage.php files in JA Newsfeatured, JA Newspro, JA Sidenews, JA Contentslider, JA Bulletin module. Because JAImage class in jaimage.php file of all these modules is loaded once only.

    Remember to clear cache from Admin area

    hiepdang Friend
    #502527

    Is there any way if i only want JA Newsfeatured, to get image from image_fulltext, other modules JA Newspro, JA Sidenews, JA Contentslider, JA Bulletin: still load as default?

    Ninja Lead Moderator
    #502654

    Yes, you can do that but you need to customize JA News Feature module

    Open 3 below files

    modules/mod_janews_featured/helpers/adapter/k2.php
    modules/mod_janews_featured/helpers/helper.php
    modules/mod_janews_featured/helpers/jaimage.php

    Find and change JAImage to JAImageFeature class name.

    Be careful to change and backup old files first, don’t forget to clear cache from Admin area after changing.

    dpchap015 Friend
    #503297

    @ninja Lead :
    <em>@Ninja Lead 385169 wrote:</em><blockquote>Yes, if you want to get only image_fulltext in Ja News Featured module, you can change this way

    From


    function parseImage($row)
    {
    //check to see if there is an intro image or fulltext image first
    $images = "";
    if (isset($row->images)) {
    $images = json_decode($row->images);
    }
    if((isset($images->image_fulltext) and !empty($images->image_fulltext)) || (isset($images->image_intro) and !empty($images->image_intro))){
    $image = (isset($images->image_intro) and !empty($images->image_intro))?$images->image_intro:((isset($images->image_fulltext) and !empty($images->image_fulltext))?$images->image_fulltext:"");
    }
    else {
    $regex = '/<img.+srcs*=s*"([^"]*)"[^>]*>/';
    $text = '';
    $text .= (isset($row->fulltext))?$row->fulltext:'';
    $text .= (isset($row->introtext))?$row->introtext:'';
    preg_match($regex, $text, $matches);
    $images = (count($matches)) ? $matches : array();
    $image = count($images) > 1 ? $images[1] : '';
    }
    return $image;
    }

    Change to


    function parseImage($row)
    {
    //check to see if there is an intro image or fulltext image first
    $images = "";
    if (isset($row->images)) {
    $images = json_decode($row->images);
    }
    if(isset($images->image_fulltext) and !empty($images->image_fulltext)){
    $image = (isset($images->image_fulltext) and !empty($images->image_fulltext))?$images->image_fulltext:"";
    }
    else {
    $regex = '/<img.+srcs*=s*"([^"]*)"[^>]*>/';
    $text = '';
    $text .= (isset($row->fulltext))?$row->fulltext:'';
    preg_match($regex, $text, $matches);
    $images = (count($matches)) ? $matches : array();
    $image = count($images) > 1 ? $images[1] : '';
    }
    return $image;
    }

    But you also need to change all jaimage.php files in JA Newsfeatured, JA Newspro, JA Sidenews, JA Contentslider, JA Bulletin module. Because JAImage class in jaimage.php file of all these modules is loaded once only.

    Remember to clear cache from Admin area</blockquote>

    Please refer to this link:
    http://www.joomlart.com/forums/topic/ja-news-featured-displays-the-2nd-image-instead-of-1st/#post-503295

    Its reverse on my case. The Ja News Featured Mod pics the 2nd image of the article as soon as i add a “Read More” to the article.
    I want the ja-news-featured to pick only 1st or intro text image always.

    I found this post to be very close to my case so i am posting it here also. If you could help, it would be great.
    I am using Teline iv

    Ninja Lead Moderator
    #503302

    @dpchap015: I replied the solution to you on this thread

Viewing 6 posts - 1 through 6 (of 6 total)

This topic contains 6 replies, has 3 voices, and was last updated by  Ninja Lead 11 years, 4 months ago.

We moved to new unified forum. Please post all new support queries in our New Forum