Hi There,
I am new to CMSMS but so far I am very impressed.
Is there a way I can have an image field and a thumbnail image field for each news article where a user can upload images to the cms (when inputting news article content)?
I would then like to retrieve these images somehow in the news templates so I can manipulate them using css.
I do not want the CMS user to have add the images and the html/css code using the WYSIWYG editor.
regards,
Dante
Image fields for News article
Re: Image fields for News article
Hi Dante,
I'm looking for exactly the same thing. If I find anything I'll pass it along.
I might end up trying to add it myself, so if I have any luck I'll let you know.
Regards,
Mikey
I'm looking for exactly the same thing. If I find anything I'll pass it along.
I might end up trying to add it myself, so if I have any luck I'll let you know.
Regards,
Mikey
Re: Image fields for News article [SOLVED]
Okay,
Here is a simple workaround. It's doesn't involve a field but may suit your needs for the time being.
In your summary template, you can insert an html image tag and link it to a specific image file relating to your article using the 'title' tag, as below.
This will then output an image with the same name as your articles 'title' field.
So if your news article is titled 'CMSMS THE CMS!' your image would be named 'CMSMS THE CMS!.jpg' with an alt tag the same.
The images must always be placed in the same folder, in my case 'uploads/images/newsImages/'.
Of course, the obvious downsides are:
Any problems feel free to PM or email me.
M
Here is a simple workaround. It's doesn't involve a field but may suit your needs for the time being.
In your summary template, you can insert an html image tag and link it to a specific image file relating to your article using the 'title' tag, as below.
Code: Select all
<img src="uploads/images/newsImages/{$entry->title}.jpg" alt="{$entry->title}" />
So if your news article is titled 'CMSMS THE CMS!' your image would be named 'CMSMS THE CMS!.jpg' with an alt tag the same.
The images must always be placed in the same folder, in my case 'uploads/images/newsImages/'.
Of course, the obvious downsides are:
- An image is always outputted. So if you don't want an image you'll have to upload a very small white jpeg, not great (especially if you have CSS borders!
- File format must always be the same
- If you change the title, you have to rename the image.
- It's abit annoying to have to name images specifically and put them in the right place.
Any problems feel free to PM or email me.
M
Last edited by myshko on Wed Feb 07, 2007 3:06 pm, edited 1 time in total.
Re: Image fields for News article [SOLVED]
Note: The whitespaces in filename can make trouble !under-radar wrote: So if your news article is titled 'CMSMS THE CMS!' your image would be named 'CMSMS THE CMS!.jpg' with an alt tag the same.
-
- Power Poster
- Posts: 322
- Joined: Sat Feb 04, 2006 1:24 am
Re: Image fields for News article
As each article has an id, you could use that instead;
Not a perfect solution, but a workaround.
Code: Select all
<img src="uploads/images/newsImages/image_{$entry->id}.jpg" alt="{$entry->title}" />
Re: Image fields for News article
Thanks guys,
Thats a good point and a good workaround
Still would be better to simply have an image field... hmmmm
Mikey
Thats a good point and a good workaround

Still would be better to simply have an image field... hmmmm
Mikey
-
- Forum Members
- Posts: 19
- Joined: Fri Dec 01, 2006 11:22 am
Re: Image fields for News article
Hi,
I found another solution which in my opinion is more comfortable and works "as it should".
You can put the thumbnail image into the news summary and format it the way you want (for example right or left aligned). Then a user defined tag extracts either the thumbnail or the rest of the summary.
How to:
Insert this user defined tag NewsSummaryExtract:
The thumbnail:
{NewsSummaryExtract extract="image" summary=$entry->summary}
The text (= the rest of the summary):
{NewsSummaryExtract extract="text" summary=$entry->summary}
Example of a news summary template:
Regards Eberhard
I found another solution which in my opinion is more comfortable and works "as it should".

You can put the thumbnail image into the news summary and format it the way you want (for example right or left aligned). Then a user defined tag extracts either the thumbnail or the rest of the summary.
How to:
Insert this user defined tag NewsSummaryExtract:
Then you can use the summary parts in your news summary template this way:$summary = $params['summary'];
$extract = $params['extract'];
if( preg_match( "/^(.*)(\]+\>)(.*)$/i", $summary, $matches ) == 1 )
{
switch( $extract )
{
case "image":
echo( $matches[2] ); break;
case "text":
default:
echo( $matches[1].$matches[3] ); break;
}
}
else if( $extract == "text" )
{
echo( $summary );
}
The thumbnail:
{NewsSummaryExtract extract="image" summary=$entry->summary}
The text (= the rest of the summary):
{NewsSummaryExtract extract="text" summary=$entry->summary}
Example of a news summary template:
Be careful not to overwrite your existing news summary template, this is only an example, which is not based on the default template.{foreach from=$items item=entry}
{if $entry->summary}
link}">
{NewsSummaryExtract extract="image" summary=$entry->summary}
{/if}
{$entry->titlelink}
{if $entry->summary}
{NewsSummaryExtract extract="text" summary=$entry->summary}
{else if $entry->content}
{eval var=$entry->content}
{/if}
{/foreach}
Regards Eberhard
Re: Image fields for News article
Brilliant function, but a word of warning. It will not work if your editor insert a -tag before the image. At least it won't for me. Switched from FCKEditor to TinyMCE, and it solved it.