# File description patch for page\_attachments

**URL:** <https://www.ruby-forum.com/t/file-description-patch-for-page-attachments/119571>\
**Category:** Radiant CMS\
**Created:** [November 8, 2007, 1:26am UTC](https://www.ruby-forum.com/t/file-description-patch-for-page-attachments/119571 "2007-11-08T01:26:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joel\_Williams](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/5fc32e/32.png) [@Joel\_Williams](https://www.ruby-forum.com/u/Joel_Williams)\
**Post date:** [November 8, 2007, 1:26am UTC](https://www.ruby-forum.com/t/file-description-patch-for-page-attachments/119571/1 "2007-11-08T01:26:49Z")

</div>

Hi all,  
I sent this to the author directly but didn’t hear back, so in case  
anyone’s  
interested, here is is a patch for the page\_attachment plugin that adds  
a  
‘description’ field. It’s not currently possible to edit the description  
without removing the file and adding it again, but that’s good enough  
for  
me!

Joel

---

<div class="post-metadata">

**Author:** ![Joel\_Williams](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/5fc32e/32.png) [@Joel\_Williams](https://www.ruby-forum.com/u/Joel_Williams)\
**Post date:** [November 8, 2007, 1:30am UTC](https://www.ruby-forum.com/t/file-description-patch-for-page-attachments/119571/2 "2007-11-08T01:30:19Z")

</div>

As far as I can tell, the attachment was stripped, so here’s the patch  
inline:

# Index: app/models/page\_attachment\_tags.rb

— app/models/page\_attachment\_tags.rb (revision 58)  
+++ app/models/page\_attachment\_tags.rb (working copy)  
@@ -35,7 +35,7 @@  
attachment.public\_filename(size)  
end

- [:content\_type, :size, :width, :height].each do |key|

- [:content\_type, :size, :width, :height, :description].each do |key|  
desc %{  
Renders the `#{key}’ attribute of the attachment.  
The ‘name’ attribute is required on this tag or the parent tag.  
The optional ‘size’  
Index: app/models/page\_attachment\_associations.rb  
===================================================================  
— app/models/page\_attachment\_associations.rb (revision 58)  
+++ app/models/page\_attachment\_associations.rb (working copy)  
@@ -4,6 +4,7 @@  
has\_many :attachments, :class\_name =\> “PageAttachment”,  
:dependent =\> :destroy

- 

```
 attr_accessor :describe_attachments
 attr_accessor :delete_attachments
 after_save :save_attachments
 after_save :destroy_attachments

```

@@ -29,11 +30,11 @@

```
 def save_attachments
   if @add_attachments

```

- 

```
   @add_attachments.each do |attachment|

```

- 

```
     attachments << PageAttachment.new(:uploaded_data => 

```

attachment)

- 

```
   @add_attachments.zip(@describe_attachments).each do 

```

|attachment, description|

- 

```
     attachments << PageAttachment.new(:uploaded_data => 

```

# attachment, :description =\> description) end end @add\_attachments = nil end end -end \ No newline at end of file +end Index: app/views/admin/page/\_attachment.rhtml

— app/views/admin/page/\_attachment.rhtml (revision 58)  
+++ app/views/admin/page/\_attachment.rhtml (working copy)  
@@ -4,6 +4,7 @@  
image\_tag(attachment.thumbnails.first.public\_filename,  
:class =\> “thumbnail”)%\>

 \<%= File.basename(attachment.public\_filename) %\>
- attachment"), “remove\_attachment(#{attachment.id})” %\>
