Opened 3 years ago

Closed 10 days ago

#11446 closed defect (bug) (fixed)

Show ellipsis after truncated filename in Media dialog

Reported by: caesarsgrunt Owned by: SergeyBiryukov
Priority: normal Milestone: 3.6
Component: General Version: 2.9
Severity: normal Keywords: has-patch dev-feedback needs-codex
Cc: bpetty

Description

Ellipses should be shown after truncated filenames in the Media dialog (and anywhere else where they are truncated, actually).

Otherwise it is sometimes hard to identify pictures.

Attachments (6)

11446-This image has a name which is too long to show fully - well let us say it has a name that is really tooo long to show fully.png (153.9 KB) - added by hakre 3 years ago.
11446.diff (820 bytes) - added by solarissmoke 2 years ago.
Add ellipsis to the end of truncated strings
11446.2.diff (6.8 KB) - added by solarissmoke 2 years ago.
11446.3.patch (6.8 KB) - added by bpetty 5 months ago.
11446.4.patch (7.0 KB) - added by bpetty 10 days ago.
11446.5.patch (9.6 KB) - added by SergeyBiryukov 10 days ago.

Download all attachments as: .zip

Change History (22)

  • Milestone changed from 2.9 to Unassigned

comment:2 follow-up: ↓ 3   hakre3 years ago

Can you provide a screenshot of the locations you see fit?

comment:3 in reply to: ↑ 2   caesarsgrunt3 years ago

Replying to hakre:

Can you provide a screenshot of the locations you see fit?

I'm not sure what you mean by the "locations you see fit".

If you mean where should there be ellipses; then the answer is anywhere a file name is truncated (at the end of the part of the name which is shown).

So for example, if I have an image called This image has a name which is too long to show fully}}, then it would currently be shown as something like {{{This image has a name. Instead, it should be This image has a name....

Alternatively we could do it the OS X way, with the ellipsis in the middle. Then it would be something like This image has ... fully.

I'll do a patch later for the first method; it shouldn't be hard.

Grrr... I hate it when Trac does that to my formatting and then won't let me fix it! Should preview, I know...

Was able to reproduce, you're right. I'll attach the image I was able to reproduce with.

Related: #11447

Related: #11417

  • Milestone changed from Unassigned to 3.1
  • Milestone changed from Awaiting Triage to Future Release

No patch.

Add ellipsis to the end of truncated strings

  • Keywords has-patch dev-feedback added; needs-patch removed

Added a patch to add an ellipsis to truncated html strings. This will however increase the returned string length beyond $count specified in wp_html_excerpt(). If this is going to be an issue then I can modify the patch to account for this.

An additional flag in wp_html_excerpt() would be nice. Something like:

function wp_html_excerpt( $str, $count, $ellipsis = false )

Otherwise this can break themes. $ellipsis can be true when you use it in the Media dialog, or other WP core places. But it should default to false.

Replying to garyc40:

An additional flag in wp_html_excerpt() would be nice. Something like:

Added this in attachment:11446.2.diff. Actually there are lots of places in core where we were adding the ellipsis manually (see patch), so adding this argument makes sense.

Changes will probably need testing to make sure nothing awkward happens - in some cases I have replaced '...' with '…'.

bpetty5 months ago

comment:13 follow-up: ↓ 15   bpetty5 months ago

  • Cc bpetty added
  • Component changed from Media to General
  • Keywords needs-codex added
  • Milestone changed from Future Release to 3.6

I've refreshed 11446.2.diff as 11446.3.patch with a minor change of using a named option array with wp_html_excerpt() for specifying extra optional settings. See coding standards for reason behind named option.

This will still need Codex updates (and I can do this) if applied.

bpetty10 days ago

comment:15 in reply to: ↑ 13   SergeyBiryukov10 days ago

Replying to bpetty:

I've refreshed 11446.2.diff as 11446.3.patch with a minor change of using a named option array with wp_html_excerpt() for specifying extra optional settings. See coding standards for reason behind named option.

A cleaner approach might be to make it a $more string, for consistency with wp_trim_words():
http://core.trac.wordpress.org/browser/tags/3.5.1/wp-includes/formatting.php#L2159

This would be more flexible and also would allow us to avoid a named entity in XML context (an issue raised in ticket:8714:27).

See 11446.5.patch.

Last edited 10 days ago by SergeyBiryukov (previous) (diff)
  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to closed

In 24214:

  • Pass ellipsis as a parameter to wp_html_excerpt() instead of appending it manually.
  • Consolidate the logic to avoid appending ellipsis if the entire string is shown.
  • Show ellipsis after truncated filenames and post titles.

props solarissmoke, bpetty, SergeyBiryukov. fixes #11446.

Note: See TracTickets for help on using tickets.