Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest sNews - sNews 1.7 - with its own forums - for discussion and user mods.

Pages: 1 [2]

Author Topic: [MOD] Article Image  (Read 4778 times)

Sven

  • ULTIMATE member
  • ******
  • Karma: 88
  • Posts: 2029
  • Chasing MY bugs!
    • hiseo.fr - rédacteur Web
Re: [MOD] Article Image
« Reply #15 on: December 27, 2010, 11:04:37 AM »

 :(
Yeap it was there but it diddn’t work. ???
I had to add description_meta to the main query and $intro_alt_text = $r['description_meta']; to make it work. :P

Sven

  • ULTIMATE member
  • ******
  • Karma: 88
  • Posts: 2029
  • Chasing MY bugs!
    • hiseo.fr - rédacteur Web
Re: [MOD] Article Image
« Reply #16 on: December 30, 2010, 09:10:25 AM »

(..) but I'm having second thoughts on that, for the above reason. Alt text -as you know- should describe the image and not be primarily used as an SEO tool for the article. Though that is just my opinion.
I got one too.  ;D
In HTML5 Alt attribute is no more mandatory.
If you want to describe the image, figure tag with its companion, figcaption, are there to inform the human or the screen reader.

But, regardless the version of HTML you’re using, in my mind, there are 2 kinds of images:
1/ the one for information
2/ the other for design

In the 1st case Alt attribute is mandatory for accessiblity reason.
In the 2nd case, the image should be placed in the background via the CSS. But sometimes this image is just here to make the article sexier  ;): so filling it with some keywords will help your page ranking.

Fred K

  • Still trying to learn stuff
  • ULTIMATE member
  • ******
  • Karma: 130
  • Posts: 2728
    • Personal
Re: [MOD] Article Image
« Reply #17 on: December 31, 2010, 12:13:09 AM »

Well, in a sense alt text has never been mandatory (e.g it is mandatory except can—should—be left empty for images that are only relevant from a design perspective). It could also be argued that even though the spec draft says alt text is now optional instead of mandatory doesn't mean that we should hurry up and drop alt text altogether. In this case, continuing to use alt text for images that are content-carrying is a *good* thing imho, and if nothing else it's backwards compatible.

Figure is obviously an alternative. I guess it comes down to personal preferences if you use figure or the "normal" image construction in conjunction with this mod. One example of usage is how I use it on frdk.com (to identify articles' category or topic relation), another example was shown earlier in this thread, where the image appears early within the article block (in that case figure would be very suitable). Anyway, changing the mod to output <figure> and <figcaption> elements is easy enough.

Also, the mod doesn't care about the HTML level... :P
Logged

luxiok

  • Newbie
  • *
  • Karma: 0
  • Posts: 1
Re: [MOD] Article Image
« Reply #18 on: January 04, 2011, 06:07:15 AM »

i can't change 2.8c ( change if else...)
Code: [Select]
if (!$_ID)  {
echo '<h2 class="big">'.$link.$uri.'/'.$r['asef'].'/">'.$title.'</a></h2>';
} else {
echo '<h2>'.$title.'</h2>';
}
}

to


Code: [Select]
if(!$_ID) {
if($artimg) {echo $link.$uri.'/'.$r['asef'].'/"><img src="'.$artimg.'" alt="'.$alt_text.'" /></a>';}
elseif(!$artimg && $_POS != 3) {echo '';}
echo '<h2 class="big">'.$link.$uri.'/'.$r['asef'].'/">'.$title.'</a></h2>';
} else {
echo '<h2>'.$title.'</h2>';
if($artimg && $_POS != 3) {echo '<img src="'.$artimg.'" alt="'.$alt_text.'" />';}
elseif(!$artimg && $_POS != 3) {echo '';}
}


my snews :Parse error: parse error in E:\xampp\htdocs\xnews\snews.php on line 3626

can you help me ??? i need :(
Logged

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6019
  • Semantically Challenged
    • snews.ca
Re: [MOD] Article Image
« Reply #19 on: January 04, 2011, 03:09:08 PM »

Line 3626 is the last line in your snews.php file.
Whenever you get this Parse Error pointing to the last line in your snews,php file... it means you have removed a necessary curly-bracket.

Curly-brackets always enclose a routine... a set of strings that do something.
This simple example starts with a condition statement, followed by an opening curly-bracket to start the routine that does something
which is to display the value generated by the $title variable as an h2 heading, followed by the closing curly-bracket to end the routine:

        if ($r['displaytitle'] == 'YES') {
                echo '<h2>'.$title.'</h2>'; // display the title value
        }

Try adding one more closing curly-bracket - } - after the part you replaced... to close the routine that starts with the string above it - if ($r['displaytitle'] == 'YES') {
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

radek

  • Newbie
  • *
  • Karma: 0
  • Posts: 4
Re: [MOD] Article Image
« Reply #20 on: February 17, 2011, 06:37:51 AM »

Works like a charm! Thank you for such nice addition.
Logged

jonathancreek

  • Newbie
  • *
  • Karma: 1
  • Posts: 19
Re: [MOD] Article Image
« Reply #21 on: December 11, 2011, 09:25:01 AM »

Article image is getting displayed in the article view also, so I am getting two images: 1. thumbnail. 2. main image.
What mistake I had done in applying the mod? Help needed.
Thanks
Logged

jonathancreek

  • Newbie
  • *
  • Karma: 1
  • Posts: 19
Re: [MOD] Article Image
« Reply #22 on: December 11, 2011, 01:37:47 PM »

Thanks  :), here's my implementation of this mod


Hi! Informix,
I would be very happy if you share how you implemented article image mod.

Thanks,

Logged

Fred K

  • Still trying to learn stuff
  • ULTIMATE member
  • ******
  • Karma: 130
  • Posts: 2728
    • Personal
Re: [MOD] Article Image
« Reply #23 on: August 20, 2012, 01:07:08 PM »

Article image is getting displayed in the article view also, so I am getting two images: 1. thumbnail. 2. main image.
What mistake I had done in applying the mod? Help needed.
Thanks

A bit late perhaps, but anyway: without seeing your actual code, I'd have to guess you've missed one step in articles, the if($_ID) { stuff goes here } else { other stuff goes here } part. If you still need help with this, show your code as it is.

This issue got me thinking though. It's easy to add a control that lets us choose if the article image should appear in both the category listing (shortened article) and the full article view, or only in one place, per article. So I went ahead and did that. See next post.
Logged

Fred K

  • Still trying to learn stuff
  • ULTIMATE member
  • ******
  • Karma: 130
  • Posts: 2728
    • Personal
Re: [MOD] Article Image
« Reply #24 on: August 20, 2012, 01:52:11 PM »

jonathancreek's issue, plus a question I got from a client, set the wheels in motion. The client issue was that they have a lot of videos on their site. They wanted to have the video poster image appear in the shortened article but not in the full article (because it would be redundant there), however they didn't want this to be the absolute design - on some articles they actually want the article image to appear both in the short and full article. So. Heres how.

The steps are almost identical to the ones we did for the image field itself, what we'll do here is to add a checkbox called "show_in_post". The box will be checked by default.

1. backup your files

2. Alter the database (we're adding a field):
Code: [Select]
ALTER TABLE  `articles` ADD  `show_in_post` ENUM(  'YES',  'NO' ) NULL DEFAULT  'YES'
3. In snews.php, function form_articles($contents), after the first switch, add (for example after $frm_showonhome):
Code: [Select]
$frm_showinpost = $r['show_in_post'] == 'YES' ? 'ok' : '';
4. Same function, after the second switch, add
Code: [Select]
$frm_showinpost = 'ok';
5. Same function, a little further down, find the html_input for your alt_text field and add after it the checkbox for show_in_post. The whole block, img_alt included, looks like this:
Code: [Select]
echo html_input('text', 'img_alt', 'alt', $frm_alt_text, l('img_alt'), '', '', '', '', '', '', '', '', '', '');
echo html_input('checkbox', 'show_in_post', 'ship', 'YES', 'Show image in article', '', '', '', '', $frm_showinpost, '', '', '', '', '');

6. In function processing(), in the first block of vars - for example after $show_on_home - add:
Code: [Select]
$show_in_post = $_POST['show_in_post'] == 'on' ? 'YES' : 'NO';
7. Same function, case (isset($_POST['add_article'])), in mysql INSERT (f.e before artorder), add show_in_post,, and then in (VALUES add '$show_in_post',

8. Same function, in mysql_query("UPDATE "._PRE.'articles'." SET, add
show_in_post='$show_in_post',
f.e before the artorder line

9. In function articles(), in each of the 3 $query_articles blocks, add
a.show_in_post

10. Same function, find the location where you added the article image string for the full article (e.g if($_ID) {}) and add a filter for show_in_post. Using the code from the original post it would be this:
Code: [Select]
if($artimg && ($_POS != 3) && ($r['show_in_post'] == 'YES')) {echo '<img src="'.$artimg.'" alt="'.$alt_text.'" />';}
If you prefer to show the article image on the full article view only, then obviously the filter goes in the if(!$_ID) {} string instead. But that is obvious, right? Also, if you want to have the article image on pages as well as articles, remove the "&& ($_POS != 3) bit.

And there you have it - a control for where the article image appears per article.
Logged
Pages: 1 [2]