-
-
Notifications
You must be signed in to change notification settings - Fork 143
Description
While testing the icon feature in the htmlpublisher-plugin, I noticed that if the user specifies a file that does not exist, the plugin does not fall back to the default icon, attempting instead to load a missing file, resulting in a broken image in the UI.
Steps to reproduce:
1) In the job configuration, set an icon to a file that does not exist
2) Run the job
3) The UI attempts to load a file that is missing, without falling back to the default icon
Proposed fix
A simple fix to this issue can be to edit the getIconFileName() method (in HtmlPublisherTarget.java), adding the check for the file existence:
public String getIconFileName() { String icon; if (StringUtils.isNotBlank(actualHtmlPublisherTarget.icon)) { if (actualHtmlPublisherTarget.icon.startsWith("symbol-")) { icon = actualHtmlPublisherTarget.icon; } else { File iconFile = new File(dir(), actualHtmlPublisherTarget.icon); if(iconFile.exists()){ icon = project.getUrl() + dir().getName() + "/" + actualHtmlPublisherTarget.icon; }else{ icon = "symbol-document-text"; } } } else { icon = "symbol-document-text"; } return dir().exists() ? icon : null; }
Would this be a useful improvement? If so, I'd be happy to submit a PR!
Originally reported by giovanni_vaccarino, imported from: Fallback to Default Icon if Specified File is Missing
- status: Open
- priority: Minor
- component(s): htmlpublisher-plugin
- resolution: Unresolved
- votes: 0
- watchers: 1
- imported: 20251211-193728
Raw content of original issue
While testing the icon feature in the htmlpublisher-plugin, I noticed that if the user specifies a file that does not exist, the plugin does not fall back to the default icon, attempting instead to load a missing file, resulting in a broken image in the UI.
Steps to reproduce: 1) In the job configuration, set an icon to a file that does not exist 2) Run the job 3) The UI attempts to load a file that is missing, without falling back to the default icon
Proposed fix A simple fix to this issue can be to edit the getIconFileName() method (in HtmlPublisherTarget.java), adding the check for the file existence:
public String getIconFileName() { String icon; if (StringUtils.isNotBlank(actualHtmlPublisherTarget.icon)) { if (actualHtmlPublisherTarget.icon.startsWith("symbol-")) { icon = actualHtmlPublisherTarget.icon; } else { File iconFile = new File(dir(), actualHtmlPublisherTarget.icon); if(iconFile.exists()){ icon = project.getUrl() + dir().getName() + "/" + actualHtmlPublisherTarget.icon; }else{ icon = "symbol-document-text"; } } } else { icon = "symbol-document-text"; } return dir().exists() ? icon : null; }Would this be a useful improvement? If so, I'd be happy to submit a PR!