switchblade1984 VIP
Total posts: 132
26 Oct 2013 12:58

Is there a way to exclude HTML Images from the intro of the HTML Field?

Last Modified: 02 Mar 2014


pepperstreet VIP
Total posts: 3,837
26 Oct 2013 15:07

By INTRO, you mean a splitted HTML-field? The first part created through ReadMore-button?


switchblade1984 VIP
Total posts: 132
26 Oct 2013 17:40

Yeah like the same way Text is hidden using the Intro Text character limit perimeter is there a way to hide the image I use in the HTML field in the Intro?, this being the Record List View.


pepperstreet VIP
Total posts: 3,837
26 Oct 2013 19:55

As far as i know, the filtering process happens before splitting the HTMLcontent into introtext/fulltext. This occurs two times: for list-view and for article-view. So, i don´t see any chance by configuration. That would require altering the field and parameters set.

Although, you might filter the field value again… in a custom field output template. So, apart from or in addition to the regular field configuration.

Rough logic/tasks:

  • parse field value for "system read-more" line
  • split value into introtext/fulltext
  • strip out IMG tags
  • concatenate intro and fulltext to value
  • output value

BTW, do you already have a lot of HTMLcontent with images? Maybe mass import? Why do you allow this kind of input at all? Maybe splitting this into multiple fields is much easier for the author and also more versatile in final output and consistant layout.


switchblade1984 VIP
Total posts: 132
27 Oct 2013 14:02

K2 is able to do this so I just assumed that Cobalt had the option built in somewhere. I like to post article with Images for references in between the text. I like to have a little bit of the article to show up as a preview of what the article is about. I guess my only option here is to make a separate intro field that is just text only.


Sackgesicht VIP
Total posts: 1,636
27 Oct 2013 16:20

I guess my only option here is to make a separate intro field that is just text only.

Your best option is to copy the HTML field output template and insert this:

<?php $this->value = preg_replace("/<img[^>]+\>/i", "", $this->value);  ?>

before the last line , like pepperstreet suggested ... :D

See this article for the template location.


switchblade1984 VIP
Total posts: 132
28 Oct 2013 10:36

Thanks guys, this got me the results I needed! =D


pepperstreet VIP
Total posts: 3,837
28 Oct 2013 17:24

You are welcome! Glad it worked out for you.

Powered by Cobalt