- Posts: 49
- Thank you received: 0
Results formatting introducing extra spacing
- sa
- Topic Author
- Offline
- Senior Member
Less
More
12 years 10 months ago #385
by sa
Results formatting introducing extra spacing was created by sa
Hi,
In some of our articles, we have 3 images surrounded by a p tag before the text content.
In the CP search results, it correctly displays the first image only, but seems to leave spacing between the image and the text. "<p align="center"> </p>"
Sometimes it leaves extra spacing even when there is only one image at the start of the article.
There is no extra spacing seen in the article content itself between the image and text, so I think it's being created by CP.
Any ideas on how to fix this?
In some of our articles, we have 3 images surrounded by a p tag before the text content.
In the CP search results, it correctly displays the first image only, but seems to leave spacing between the image and the text. "<p align="center"> </p>"
Sometimes it leaves extra spacing even when there is only one image at the start of the article.
There is no extra spacing seen in the article content itself between the image and text, so I think it's being created by CP.
Any ideas on how to fix this?
Please Log in or Create an account to join the conversation.
- andrea_4g
- Offline
- Administrator
Less
More
- Posts: 1122
- Thank you received: 163
12 years 10 months ago #392
by andrea_4g
Replied by andrea_4g on topic Re: Results formatting introducing extra spacing
That '<p align="center">...' doesn't look like Custom Properties HTML output.
Here's CP rendering of the thumbnail image (no <p> tags inside)
My guess is that images - in those articles - are indeed surrounded by <p align="center">. When preparing the results, Custom Properties strips all them images from the article, leaving untouched all other tags. So, only those empty <p>, formerly sourrounding the images, remain.
Here's CP rendering of the thumbnail image (no <p> tags inside)
Code:
<div style="width: 100px; height: 100px;" class="cp_image"><a href="/wine/14-pink-wines/23-salice-salentino-rose.html"><img width="65" height="100" class="cp_image" title="Salice salentino rosè" alt="Salice salentino rosè" src="/components/com_customproperties/images/wine/salice_thumb.jpg"/></a></div>
My guess is that images - in those articles - are indeed surrounded by <p align="center">. When preparing the results, Custom Properties strips all them images from the article, leaving untouched all other tags. So, only those empty <p>, formerly sourrounding the images, remain.
Please Log in or Create an account to join the conversation.
- sa
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 49
- Thank you received: 0
12 years 10 months ago #394
by sa
Replied by sa on topic Re: Results formatting introducing extra spacing
Yes, I think you're right. There seems to be a correspondence between the number of and the number of imgs beyond 1. The question is what is the best solution to fix this?
I see here a solution for wordpress that strips the p tags off of images: css-tricks.com/snippets/wordpress/remove...-from-around-images/
Is it possible to add run this function on the content before the CP processsing?
or would it be better to write a php function to remove any p tags containing only 's
Thanks
I see here a solution for wordpress that strips the p tags off of images: css-tricks.com/snippets/wordpress/remove...-from-around-images/
Is it possible to add run this function on the content before the CP processsing?
or would it be better to write a php function to remove any p tags containing only 's
Thanks
Please Log in or Create an account to join the conversation.
- andrea_4g
- Offline
- Administrator
Less
More
- Posts: 1122
- Thank you received: 163
12 years 10 months ago - 12 years 10 months ago #396
by andrea_4g
Replied by andrea_4g on topic Re: Results formatting introducing extra spacing
The solution you posted does a different thing: removes <p> around the image; you'll then have have all images inside you articles without the surrounding <p>, whether you like it or not (<p> are usually there with a purpose, such as controlling the correct positioning).
Manipulating an HTML text is quite a tricky subject, usually resource intensive, that easily leads to undesired results. If we managed to include a function to strip <p> around images we could very possibly strip legit text.
For example, a code like:
Would be *very* problematic to handle.
So, to solve the problem I'd try using the Title + Plain Text + Image view, instead of the Title + HTML Intro. If you don't need HTML elements in search results, that will work.
Manipulating an HTML text is quite a tricky subject, usually resource intensive, that easily leads to undesired results. If we managed to include a function to strip <p> around images we could very possibly strip legit text.
For example, a code like:
Code:
<p> some text <img src="something"/> other text <p> a nested paragraph</p> more text </p>
So, to solve the problem I'd try using the Title + Plain Text + Image view, instead of the Title + HTML Intro. If you don't need HTML elements in search results, that will work.
Last edit: 12 years 10 months ago by andrea_4g.
Please Log in or Create an account to join the conversation.
- sa
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 49
- Thank you received: 0
12 years 10 months ago #397
by sa
Replied by sa on topic Re: Results formatting introducing extra spacing
This suggestion works perfectly. Thanks!
Please Log in or Create an account to join the conversation.
Time to create page: 0.176 seconds