#10703 closed enhancement (fixed)
Logarithmic scale for tag cloud tag size
Reported by: | kometbomb | Owned by: | |
---|---|---|---|
Milestone: | 2.9 | Priority: | normal |
Severity: | normal | Version: | 2.8.4 |
Component: | Template | Keywords: | has-patch |
Focuses: | Cc: |
Description
The tag clouds generated by wp_tag_cloud() tend to work poorly if there's one or two dominant tags, i.e. the tag could has very many small tags and one or two huge tags. This can be avoided by not resizing the tags by the normalized absolute post count but by the normalized log10 of the count. This makes the offending "peak" tags smaller.
Here's a patch that adds a new boolean arg for wp_tag_cloud() called 'logarithmic'. The default is false which makes wp_tag_cloud() generate the same cloud as before, setting the arg to true makes wp_tag_cloud() generate a tag cloud with the tag sizes based on log10.
Attachments (1)
Change History (8)
#2
@
15 years ago
- Keywords has-patch added; tag cloud tags removed
- Milestone changed from Unassigned to 2.9
Looking purely at the example you've given, i'd actually support making log10 the default.
#3
@
15 years ago
+1 dd32's suggestion. If this logarithmic sizing is included though, maybe shorten it from 'logarithmic' to just 'log10'. I think a better option, if the an extra parameter like 'logarithmic' is desirable, is to have log10 be the default, and provide the ability to give any callback function name as the scale determination factor.
#4
@
15 years ago
- Keywords needs-patch added; has-patch removed
I've put it on my site: http://scribu.net/tags
And I also think it should be the default.
However, with the current patch, the displayed count is also inflated.
For example: hovering over Viewer2 tag shows "136 topics" with log10 and "22 topics" without (the real number).
#5
@
15 years ago
- Keywords has-patch added; needs-patch removed
Ok, thanks for your input. I fixed the issue with the alt text and added a callback parameter (topic_count_scale_callback). Also, it now defaults to log10 since I detected some sort of consensus.
#7
@
15 years ago
Awesome. The bad results for long-tail tags has always bugged me, and I kept meaning to do something like this myself. But I didn't think of using a log function for the scaling. Much simpler than what I had in mind, which was to just linearly scale the tags in their count order (as opposed to the count value).
The difference can be seen here: http://kometbomb.net/tags/