Page 1 of 1

unfetched image URLs push aside content

Posted: 20 Apr 2016, 19:24
by icewater
I have disabled fetching of images, but the image's URL is still displayed next the the article. The URL can be quite long, and often pushes the article content off the edge of the screen, and/or into a long table cell that is about one word wide.

Is there any way to prevent this?

I see this with the default theme, and with the feedly theme.

Thanks

Re: unfetched image URLs push aside content

Posted: 20 Apr 2016, 20:03
by fox
you can make a plugin that would remove images altogether

Re: unfetched image URLs push aside content

Posted: 20 Apr 2016, 23:20
by nameless
While I don't use this feature at all I think this may be an enhancement which should be pushed to core since this is kinda useful.
I just disabled images for testing puporses and image URL can indeed fuck up formatting.

Maybe ttrss could output URLs something like this:
https://some domain.TLD/.../image.jpg
What I am trying to point to is to shorten arbitrary parts of the URL by not displaying the whole URL.

I don't know hard implementing something like this is going to be though.

Re: unfetched image URLs push aside content

Posted: 21 Apr 2016, 03:54
by JustAMacUser
There's a truncate_string function in the core, but it trims the end (e.g. for article excerpts). But something like this might work: http://stackoverflow.com/a/16869330

Re: unfetched image URLs push aside content

Posted: 21 Apr 2016, 08:25
by Masiosare
This should probably work.

Code: Select all

$url_parts = parse_url($url);
$domain = $url_parts["host"];
$file = basename($url_parts["path"]);
if(preg_match('/(jpg|jpeg|png|gif)+$/', $url)){
   $anchor = "<a href='$url'>$file </a>";
}

Re: unfetched image URLs push aside content

Posted: 21 Apr 2016, 17:00
by JustAMacUser
Masiosare,

That code is horribly inefficient for what needs to be done. The link I posted will quickly remove the middle part from long URLs so you can at least see the domain and file name. If the URL is short, everything is shown, if it's long then it's truncated.

The code you posted shows the file name. That could be done in one line. Literally. Without using expensive PCRE, which is not really necessary for a variety of reasons.

Re: unfetched image URLs push aside content

Posted: 21 Apr 2016, 17:50
by fox
Masiosare wrote:This should probably work.

Code: Select all

$url_parts = parse_url($url);
$domain = $url_parts["host"];
$file = basename($url_parts["path"]);
if(preg_match('/(jpg|jpeg|png|gif)+$/', $url)){
   $anchor = "<a href='$url'>$file </a>";
}


quoting this abomination for posterity

Re: unfetched image URLs push aside content

Posted: 21 Apr 2016, 17:56
by Masiosare
It's a different solution. I use it on a site to do something like this:

Image

Yeah, you could do that with a single str_replace with multiple needles too. Hopefully your server won't explode for using a single regex.