E107: Question: How add more media to news?

Created on 6 Jun 2016  路  11Comments  路  Source: e107inc/e107

How can we add more media to news?
I'm creating a site, and i really need more than the currently available 5 media slots for images / videos (that's the ones available when editing a news article...)

question

All 11 comments

@rica-carv Are you sure they need to be in a template, and can't just be added to the "Body" ?

@CaMer0n I quite doesn't understand your question....
When you edit news in admin area, you only have 5 slots for media.
If you need more, you can't add more, not even by templating admin interface, since the core code only uses 5 media slots....
As far i can see it, this could be controled easilly by any user, just by adding a "max media in news" field, and make news editor template use the slots indicated in that field....
Just my thoughts....
Anyway, right now i can override this by just insert more media directly on the database.... wich shouldn't be the correct way.....

Just my opinion:
I am afraid with this sort of change something could go wrong with core files and it's not worth that risk. Core solution should be so easy as can be.

I've solved this before by my plugin with connecting news with gallery category. Then you can have so many images you can.
And I suppose if you do your own plugin on news table just for media fields, you can have the same result (without mess with database)

I've seen solution you need in content plugin. You should set number of images for news category not for news itself.

Yes, it would be great, but there are other urgent issues to solve.

@rica-carv Yes, you have designated slots for media + the BODY and EXTENDED fields which can have an unlimited number of images/videos etc.
I would be interested to see how your template would make use of 10 media slots (for example).
Could you post a screenshot?
Was the idea to have a media-gallery on the news item?

@Jimmi08 I can't see how this could really do a mess on the core files... As i see it, it would only require change a few code lines, and it won't even have to mess with the database, it would be just user input, nothing more... but hey, as i've stated before, i can live with it....
No, i can't set the images to the news category (wich would set it global to that category), i will have to set those images to every single news item, because for instance, one news item might have 5 media items, and the next might have 10, and the next one 7, and so on, all within the same category...
@CaMer0n Yes, i know i can have images in the body and extended fileds, but i'm pushing things a litlle bit further....
For instance, imagine that in the news LIST view, instead of one static image (the first one is always displayed, if that matters), you could have a small caroussel or a fading images slideshow, with ALL the images you have for that specific news article???
Further more, on the news body itself i can use that same images with the NEWSIMAGE shortcode, so every single media i link to that news, is directly updated in both places. That way, i only need to change images on the news edit window, nothing more. Got my point?

@rica-carv Yes, exactly my point. You want number to news, other wants them set for category, other just change number for all news. I would support to add preference for this (in your case it would be 10, you just let not used other empty)

@CaMer0n it was page, not news, too long ago, I forgot details, sorry, I need to refresh it - the chapter had it's own pages (core), chapter had its own events and it's own gallery. Chapter = team, gallery - photos of team members (players cards), events = team games, pages - stories about that team. Everything displayed together on one page. It was at alfa time, now I would do this different way. They use WP now so I can't show you this.

I spoke with @rica-carv in the chatroom. What he's trying to do is completely unrelated to news, however I have recommended that he write a simple plugin to integrate into the news admin area using e_admin.php which will provide the additional options he requires. (including more images)

Hi it is possible.. i am working on a site that needs a lot of photo's example is here.. https://rickrealestate.nl/news/view/1/in-verkoop/2e-van-blankenburgstraat-93-den-haag

In admin/newspost.php

            $text = $frm->imagepicker('news_thumbnail[0]', varset($thumbTmp[0]),'','media=news&video=1');
            $text .= $frm->imagepicker('news_thumbnail[1]', varset($thumbTmp[1]),'','media=news&video=1');
            $text .= $frm->imagepicker('news_thumbnail[2]', varset($thumbTmp[2]),'','media=news&video=1');
            $text .= $frm->imagepicker('news_thumbnail[3]', varset($thumbTmp[3]),'','media=news&video=1');
            $text .= $frm->imagepicker('news_thumbnail[4]', varset($thumbTmp[4]),'','media=news&video=1');
            $text .= $frm->imagepicker('news_thumbnail[5]', varset($thumbTmp[5]),'','media=news&video=1');
            $text .= $frm->imagepicker('news_thumbnail[6]', varset($thumbTmp[6]),'','media=news&video=1');
            $text .= $frm->imagepicker('news_thumbnail[7]', varset($thumbTmp[7]),'','media=news&video=1');
            $text .= $frm->imagepicker('news_thumbnail[8]', varset($thumbTmp[8]),'','media=news&video=1');
            $text .= $frm->imagepicker('news_thumbnail[9]', varset($thumbTmp[9]),'','media=news&video=1');

And in newstemplate.php i just entered:

            <div class="row" id="mg-grid">

            <figure class="col-md-3 mg-gallery-item"><a href={NEWSIMAGE: item=2} data-lightbox-gallery="rooms"><img src={NEWSIMAGE: item=2} class="img-responsive" alt="" /><span class="mg-gallery-overlayer"><i class="fa fa-search-plus"></i></span></a></figure>

            <figure class="col-md-3 mg-gallery-item"><a href={NEWSIMAGE: item=3} data-lightbox-gallery="rooms"><img src={NEWSIMAGE: item=3} class="img-responsive" alt="" /><span class="mg-gallery-overlayer"><i class="fa fa-search-plus"></i></span></a></figure>

            <figure class="col-md-3 mg-gallery-item"><a href={NEWSIMAGE: item=4} data-lightbox-gallery="rooms"><img src={NEWSIMAGE: item=4} class="img-responsive" alt="" /><span class="mg-gallery-overlayer"><i class="fa fa-search-plus"></i></span></a></figure>

            <figure class="col-md-3 mg-gallery-item"><a href={NEWSIMAGE: item=5} data-lightbox-gallery="rooms"><img src={NEWSIMAGE: item=5} class="img-responsive" alt="" /><span class="mg-gallery-overlayer"><i class="fa fa-search-plus"></i></span></a></figure>
            </div>

            <div class="row" id="mg-grid">
            <figure class="col-md-3 mg-gallery-item"><a href={NEWSIMAGE: item=6} data-lightbox-gallery="rooms"><img src={NEWSIMAGE: item=6} class="img-responsive" alt="" /><span class="mg-gallery-overlayer"><i class="fa fa-search-plus"></i></span></a></figure>

            <figure class="col-md-3 mg-gallery-item"><a href={NEWSIMAGE: item=7} data-lightbox-gallery="rooms"><img src={NEWSIMAGE: item=7} class="img-responsive" alt="" /><span class="mg-gallery-overlayer"><i class="fa fa-search-plus"></i></span></a></figure>

            <figure class="col-md-3 mg-gallery-item"><a href={NEWSIMAGE: item=8} data-lightbox-gallery="rooms"><img src={NEWSIMAGE: item=8} class="img-responsive" alt="" /><span class="mg-gallery-overlayer"><i class="fa fa-search-plus"></i></span></a></figure>

            <figure class="col-md-3 mg-gallery-item"><a href={NEWSIMAGE: item=9} data-lightbox-gallery="rooms"><img src={NEWSIMAGE: item=9} class="img-responsive" alt="" /><span class="mg-gallery-overlayer"><i class="fa fa-search-plus"></i></span></a></figure>
            </div>

And it works! But how many images would be needed... in this case i need it to be max 28.. :-)

@Alex-e107nl Yes, you can do that, but you'll be messing with core newspost.php file, wich will be overwritten on every update, and therefore, you'll miss those changes everytime.
And have all that HTML "hardcoded" in newstemplate.php is a little bit unfriendly, since imagine you want to change the layout of a specific news item? I would prefer enter that HTML in the news itself.....

Anyway, i've solved temporarly the amount of images available by simply entering more filenames on the news image field, directly on the database, and voil谩, all solved.... No messing with core files.... Just some database mock up... :laughing:

As far i can see it, this could be solved on admin area just by some simple code change and a new field to restrict the maximum number of media allowed per news item....

@CaMer0n Thanks

You're welcome.

Was this page helpful?
0 / 5 - 0 ratings