- Timestamp:
- 2020-08-30T23:20:05+02:00 (4 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/ImageProvider.java
r16984 r16988 1085 1085 } 1086 1086 } else { 1087 final String fnMD5 = Utils.md5Hex(fn); 1088 url = b + fnMD5.substring(0, 1) + '/' + fnMD5.substring(0, 2) + '/' + fn; 1087 url = Mediawiki.getImageUrl(b, fn); 1089 1088 } 1090 1089 result = getIfAvailableHttp(url, type); -
trunk/src/org/openstreetmap/josm/tools/Mediawiki.java
r15261 r16988 74 74 return Optional.empty(); 75 75 } 76 77 /** 78 * Computes the URL for the given filename on the MediaWiki server 79 * @param fileBaseUrl the base URL of the file MediaWiki storage, such as {@code "https://upload.wikimedia.org/wikipedia/commons/"} 80 * @param filename the filename 81 * @return the URL for the given filename on the MediaWiki server 82 * @see <a href="https://www.mediawiki.org/wiki/Manual:$wgHashedUploadDirectory">MediaWiki $wgHashedUploadDirectory</a> 83 */ 84 public static String getImageUrl(String fileBaseUrl, String filename) { 85 final String md5 = Utils.md5Hex(filename); 86 return String.join("/", Utils.strip(fileBaseUrl, "/"), md5.substring(0, 1), md5.substring(0, 2), filename); 87 } 76 88 }
Note:
See TracChangeset
for help on using the changeset viewer.