Results formatting introducing extra spacing

  • sa
  • Autore della discussione
  • Offline
  • Anziano Utente
  • Anziano Utente
Di più
12 Anni 10 Mesi fa #385 da 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">&nbsp;&nbsp;</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?

Si prega Accesso o Crea un account a partecipare alla conversazione.

Di più
12 Anni 10 Mesi fa #392 da andrea_4g
Risposta da andrea_4g al 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)
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.

Si prega Accesso o Crea un account a partecipare alla conversazione.

  • sa
  • Autore della discussione
  • Offline
  • Anziano Utente
  • Anziano Utente
Di più
12 Anni 10 Mesi fa #394 da sa
Yes, I think you're right. There seems to be a correspondence between the number of &nbsp; 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 &nbsp;'s

Thanks

Si prega Accesso o Crea un account a partecipare alla conversazione.

Di più
12 Anni 10 Mesi fa - 12 Anni 10 Mesi fa #396 da andrea_4g
Risposta da andrea_4g al 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:
Code:
<p> some text <img src="something"/> other text <p> a nested paragraph</p> more text </p>
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.
Ultima Modifica 12 Anni 10 Mesi fa da andrea_4g.

Si prega Accesso o Crea un account a partecipare alla conversazione.

  • sa
  • Autore della discussione
  • Offline
  • Anziano Utente
  • Anziano Utente
Di più
12 Anni 10 Mesi fa #397 da sa
This suggestion works perfectly. Thanks!

Si prega Accesso o Crea un account a partecipare alla conversazione.

Tempo creazione pagina: 0.136 secondi