Skip to content

Commit f5ab0f3

Browse files
committed
enhancements to the HTML processing
1 parent 162c32b commit f5ab0f3

File tree

2 files changed

+62
-11
lines changed

2 files changed

+62
-11
lines changed

cloudinary-taglib/src/main/java/com/cloudinary/taglib/CloudinaryUploadTag.java

Lines changed: 47 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,15 @@
1313

1414
public class CloudinaryUploadTag extends SimpleTagSupport {
1515

16-
private String resourceType = "auto";
16+
// HTML basics
17+
private String id = null;
18+
private String name = "file";
19+
private String extraClasses = null;
20+
21+
// Cloudinary Specific
22+
private String tags = null;
1723
private String fieldName;
18-
private String extraClasses;
24+
private String resourceType = "auto";
1925

2026
public void doTag() throws JspException, IOException {
2127
Cloudinary cloudinary = Singleton.getCloudinary();
@@ -29,10 +35,16 @@ public void doTag() throws JspException, IOException {
2935

3036
Map<String, String> attributes = new HashMap<String, String>();
3137
attributes.put("type", "file");
32-
attributes.put("name", "file");
38+
attributes.put("name", name);
39+
if (id != null) {
40+
attributes.put("id", id);
41+
}
3342

3443
Map<String, String> options = new HashMap<String, String>();
3544
options.put("resource_type", resourceType);
45+
if (tags != null) {
46+
options.put("tags", tags);
47+
}
3648

3749
String cloudinaryUrl = cloudinary.cloudinaryApiUrl("upload", options);
3850

@@ -65,20 +77,20 @@ public void doTag() throws JspException, IOException {
6577
getJspContext().getOut().println(renderedHtml.toString());
6678
}
6779

68-
public void setResourceType(String resourceType) {
69-
this.resourceType = resourceType;
80+
public void setId(String id) {
81+
this.id = id;
7082
}
7183

72-
public String GetResourceType() {
73-
return resourceType;
84+
public String getId() {
85+
return id;
7486
}
7587

76-
public void setFieldName(String fieldName) {
77-
this.fieldName = fieldName;
88+
public void setName(String name) {
89+
this.name = name;
7890
}
7991

80-
public String getFieldName() {
81-
return fieldName;
92+
public String getName() {
93+
return name;
8294
}
8395

8496
public void setExtraClasses(String extraClasses) {
@@ -89,4 +101,28 @@ public String getExtraClasses() {
89101
return extraClasses;
90102
}
91103

104+
public void setTags(String tags) {
105+
this.tags = tags;
106+
}
107+
108+
public String getTags() {
109+
return tags;
110+
}
111+
112+
public void setFieldName(String fieldName) {
113+
this.fieldName = fieldName;
114+
}
115+
116+
public String getFieldName() {
117+
return fieldName;
118+
}
119+
120+
public void setResourceType(String resourceType) {
121+
this.resourceType = resourceType;
122+
}
123+
124+
public String GetResourceType() {
125+
return resourceType;
126+
}
127+
92128
}

cloudinary-taglib/src/main/resources/META-INF/cloudinary.tld

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,21 @@
1515
<required>true</required>
1616
<rtexprvalue>true</rtexprvalue>
1717
</attribute>
18+
<attribute>
19+
<name>id</name>
20+
<required>false</required>
21+
<rtexprvalue>true</rtexprvalue>
22+
</attribute>
23+
<attribute>
24+
<name>name</name>
25+
<required>false</required>
26+
<rtexprvalue>true</rtexprvalue>
27+
</attribute>
28+
<attribute>
29+
<name>tags</name>
30+
<required>false</required>
31+
<rtexprvalue>true</rtexprvalue>
32+
</attribute>
1833
<attribute>
1934
<name>extraClasses</name>
2035
<required>false</required>

0 commit comments

Comments
 (0)