unfetched image URLs push aside content

Support requests, bug reports, etc. go here. Dedicated servers / VDS hosting only
icewater
Bear Rating Trainee
Bear Rating Trainee
Posts: 3
Joined: 20 Apr 2016, 19:22

unfetched image URLs push aside content

Postby icewater » 20 Apr 2016, 19:24

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

User avatar
fox
^ me reading your posts ^
Posts: 6318
Joined: 27 Aug 2005, 22:53
Location: Saint-Petersburg, Russia
Contact:

Re: unfetched image URLs push aside content

Postby fox » 20 Apr 2016, 20:03

you can make a plugin that would remove images altogether

nameless
Bear Rating Master
Bear Rating Master
Posts: 126
Joined: 28 Aug 2013, 20:33

Re: unfetched image URLs push aside content

Postby nameless » 20 Apr 2016, 23:20

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.

JustAMacUser
Bear Rating Overlord
Bear Rating Overlord
Posts: 373
Joined: 20 Aug 2013, 23:13

Re: unfetched image URLs push aside content

Postby JustAMacUser » 21 Apr 2016, 03:54

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

Masiosare
Bear Rating Trainee
Bear Rating Trainee
Posts: 22
Joined: 23 May 2013, 01:08

Re: unfetched image URLs push aside content

Postby Masiosare » 21 Apr 2016, 08:25

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>";
}

JustAMacUser
Bear Rating Overlord
Bear Rating Overlord
Posts: 373
Joined: 20 Aug 2013, 23:13

Re: unfetched image URLs push aside content

Postby JustAMacUser » 21 Apr 2016, 17:00

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.

User avatar
fox
^ me reading your posts ^
Posts: 6318
Joined: 27 Aug 2005, 22:53
Location: Saint-Petersburg, Russia
Contact:

Re: unfetched image URLs push aside content

Postby fox » 21 Apr 2016, 17:50

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

Masiosare
Bear Rating Trainee
Bear Rating Trainee
Posts: 22
Joined: 23 May 2013, 01:08

Re: unfetched image URLs push aside content

Postby Masiosare » 21 Apr 2016, 17:56

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.


Return to “Support”

Who is online

Users browsing this forum: No registered users and 8 guests