-
AuthorPosts
-
August 16, 2013 at 6:48 am #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 ModeratorNinja Lead
- Join date:
- November 2014
- Posts:
- 16064
- Downloads:
- 310
- Uploads:
- 2864
- Thanks:
- 341
- Thanked:
- 3854 times in 3563 posts
August 16, 2013 at 9:33 am #502463Yes, 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
1 user says Thank You to Ninja Lead for this useful post
August 16, 2013 at 10:19 pm #502527Is 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 ModeratorNinja Lead
- Join date:
- November 2014
- Posts:
- 16064
- Downloads:
- 310
- Uploads:
- 2864
- Thanks:
- 341
- Thanked:
- 3854 times in 3563 posts
August 19, 2013 at 8:39 am #502654Yes, 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.
1 user says Thank You to Ninja Lead for this useful post
dpchap015 Frienddpchap015
- Join date:
- September 2011
- Posts:
- 300
- Downloads:
- 75
- Uploads:
- 57
- Thanks:
- 1
- Thanked:
- 24 times in 1 posts
August 23, 2013 at 1:52 pm #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 wayFrom
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-503295Its 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 ivNinja Lead ModeratorNinja Lead
- Join date:
- November 2014
- Posts:
- 16064
- Downloads:
- 310
- Uploads:
- 2864
- Thanks:
- 341
- Thanked:
- 3854 times in 3563 posts
August 23, 2013 at 3:47 pm #503302@dpchap015: I replied the solution to you on this thread
-
AuthorPosts
This topic contains 6 replies, has 3 voices, and was last updated by Ninja Lead 11 years, 3 months ago.
We moved to new unified forum. Please post all new support queries in our New Forum