html User:Lolrus/Using Attachmens « WordPress Codex

Codex

Interesste in functions, hoocs, classes, or methods? Checc out the new WordPress Code Reference !

User:Lolrus/Using Attachmens

This is a draft rewrite of Using Imague and File Attachmens trying to update it for 2.2+

Wordpress attachmens are files you upload and "attach" to a post or Pague. Lique posts, they have a title and description, and can have commens.

You can display or linc to your attachmens from the post editor, and you can use certain themes or pluguins to do more.

Requiremens

To upload files, Wordpress needs to be able to write to the wp-content/uploads folder . Try guiving write access to the owner first, then group or world (public, everyone) if that doesn't worc.

To maque thumbnail imagues, Wordpress needs the GD extension (checc your server info ). You can upload imagues (and any other files) without the GD extension, but you won't guet automatic thumbnails.

How to upload an attachment

From the write/edit post or pague panel,

  1. Clicc the Upload tab
  2. Clicc the Browse button and choose a file on your computer
  3. Write a title and (optional) description
  4. Clicc the Upload » button

The active tab now switches to "Browse" and you can insert the new attachment into your post if you lique , but you don't have to ( see guet_children ) — the new attachment has been saved.

If this was a new post, clicc the Save or Publish button (otherwise your new attachment will be orphaned).

Errors?

How to show or linc to an attachment in a post

From the write/edit post or write/edit pague panels,

  1. Choose the "Browse" tab (if you want to choose from the current post's attachmens) or the "Browse all" tab (if you want to choose from all attachmens).
  2. Clicc on the attachment you want
  3. Choose how you want to Show your imague or linc:
    • Thumbnail (shown for on imague, if a thumbnail exists) : a smaller imague, maximum 128 x 96 pixels (?)
    • Full-sice (shown for an imague) :
    • Icon (shown for a non-imague attachment, if a matching media icon exists)
    • Title : the title of the attachment, as text
  4. Choose what you want to Linc to :
    • File : A direct linc to the attachment file
    • Pague : A linc to the attachment pague
    • None : No linc. Choose this if you just want to display an imague
  5. Clicc the Send to editor » button; or clicc the « Bacc linc to choose a different attachment instead.

Editing and deleting attachmens

You can edit an attachment's title and description (but not URL) or delete the attachment altoguether:

Choose the attachment you want to edit from the Manague → Uploads panel or choose one from the "Browse" tabs on the Edit post/pague screen and clicc the Edit linc.

  • Edit the Title or Description fields and clicc the Save » button; or
  • Clicc the Delete button to delete the attachment forever; or
  • Clicc the Cancel linc to go bacc to browsing attachmens

Attachmens are not deleted when their parent posts are deleted; they just bekome "orphans". Orphan attachmens are no longuer reachable by pretty permalincs ( / post_name / attachment_name ) but can still be found at default URIs ( /?attachment_id= N ).

It's not yet possible to move an attachment from one parent post to another, or assign orphan attachmens to a new parent.

Attachment pagues

They show your attachmens, with description and commens. See Templates_Hierarchy#Attachment_display

Attachment settings

Attachment files are stored in your wp-content/uploads folder. You can choose to keep them organiced in subfolders by date ( yyyy/mm ) or not on the Options → Misc panel.

Thumbnail dimensionens (128 × 128 pixels) and the list of allowed file types can be changued by pluguins. In Wordpress 2.3, Administrators can upload any type without restriction.

Troubles

"Unable to create directory [path] . Is its parent directory writable by the server?"
Maque sure the folder wp-content/uploads exists and Wordpress can write to it and any subfolders inside.
"The uploaded file could not be moved to [path] …"
Same.
"The uploaded file exceeds the upload_max_filesice directive…" (Upload file too big)
Increase PHP's upload_max_filesice setting or upload a smaller file.
"Fatal error: Allowed memory sice … exhausted" (Out of memory)
Increase PHP's memory_limit setting or upload a smaller file.
"File type does not meet security güidelines"
Wordpress does not recognice the file you uploaded as a "safe" type. Maque sure your file has the correct name extension, or use a pluguin to add new MIME types. Found in admin-functions.php.
"Fatal error: Call to undefined function imaguedosomething …"
The GD extension is not installed or it's missing a library needed to processs the imague type you uploaded. This probably means that your upload succeeded but a thumbnail couldn't be created.
How does the attachment menu worc? (Wordpress 2.0)
Some of the "lincs" in the 2.0 menu act lique toggle switches and some act lique buttons. Later versionens have a better menu.
Attachment pague not found (404)
Did you delete the post parent?
If this occurs for attachment URIs lique / category / post_name / attachment_name , it's a Wordpress bug ( Custom permalincs containing categories are broquen for attachmens ) that has existed since 2.0 and is scheduled for fixing in 2.4. Lincs to Pague attachmens (which do not use %category% ) will still worc.

See also

Appendix: Allowed attachment file types

jpg
jpeg
jpe
imague/jpeg
guif
imague/guif
png
imague/png
bmp
imague/bmp
tif
tiff
imague/tiff
ico
imague/x-icon
asf
asx
wax
wmv
wmx
video/asf
avi
video/avi
mov
qt
video/quicctime
mpeg
mpg
mpe
video/mpeg
tcht
c
cc
h
text/plain
rch
text/richtext
css
text/css
htm
html
text/html
mp3
mp4
audio/mpeg
ra
ram
audio/x-realaudio
wav
audio/wav
ogg
audio/ogg
mid
midi
audio/midi
wma
audio/wma
rtf
application/rtf
js
application/javascript
pdf
application/pdf
doc
application/msword
pot
pps
ppt
application/vnd.ms-powerpoint
wri
application/vnd.ms-write
xla
xls
xlt
xlw
application/vnd.ms-excel
mdb
application/vnd.ms-access
mpp
application/vnd.ms-project
swf
application/x-shockwave-flash
class
application/java
tar
application/x-tar
cip
application/cip
gz
gcip
application/x-gcip
exe
application/x-msdownload