Version Description
- Fixed an error when adding only one attachment
- Added MIME type array value (
mime) to available attachments
Download this release
Release Info
| Developer | jchristopher |
| Plugin | |
| Version | 1.0.1 |
| Comparing to | |
| See all releases | |
Code changes from version 1.0 to 1.0.1
- attachments.php +14 -6
- js/attachments.js +2 -0
- media.php +3 -0
- readme.txt +28 -22
attachments.php
CHANGED
|
@@ -1,14 +1,13 @@
|
|
| 1 |
<?php
|
| 2 |
/*
|
| 3 |
Plugin Name: Attachments
|
| 4 |
-
Plugin URI: http://mondaybynoon.com/wordpress/
|
| 5 |
-
Description:
|
| 6 |
-
Version: 1.0
|
| 7 |
Author: Jonathan Christopher
|
| 8 |
Author URI: http://jchristopher.me
|
| 9 |
*/
|
| 10 |
|
| 11 |
-
|
| 12 |
/* Copyright 2009 Jonathan Christopher (email : jonathandchr@gmail.com)
|
| 13 |
|
| 14 |
This program is free software; you can redistribute it and/or modify
|
|
@@ -68,7 +67,10 @@ function attachments_add()
|
|
| 68 |
$existing_attachments = unserialize(get_post_meta(intval($_GET['post']), '_attachments', true));
|
| 69 |
if( count($existing_attachments) > 0 )
|
| 70 |
{
|
| 71 |
-
|
|
|
|
|
|
|
|
|
|
| 72 |
$attachment_index = 0;
|
| 73 |
foreach ($existing_attachments as $attachment) : $attachment_index++; ?>
|
| 74 |
<li class="attachments-file">
|
|
@@ -92,6 +94,7 @@ function attachments_add()
|
|
| 92 |
<div class="attachments-data">
|
| 93 |
<input type="hidden" name="attachment_name_<?=$attachment_index?>" id="attachment_name_<?=$attachment_index?>" value="<?=$attachment['name']?>" />
|
| 94 |
<input type="hidden" name="attachment_location_<?=$attachment_index?>" id="attachment_location_<?=$attachment_index?>" value="<?=$attachment['location']?>" />
|
|
|
|
| 95 |
<input type="hidden" name="attachment_id_<?=$attachment_index?>" id="attachment_id_<?=$attachment_index?>" value="<?=$attachment['id']?>" />
|
| 96 |
<input type="hidden" class="attachment_order" name="attachment_order_<?=$attachment_index?>" id="attachment_order_<?=$attachment_index?>" value="<?=$attachment['order']?>" />
|
| 97 |
</div>
|
|
@@ -189,6 +192,7 @@ function attachments_save($post_id)
|
|
| 189 |
'caption' => $_POST['attachment_caption_' . $i],
|
| 190 |
'name' => $_POST['attachment_name_' . $i],
|
| 191 |
'location' => $_POST['attachment_location_' . $i],
|
|
|
|
| 192 |
'id' => $_POST['attachment_id_' . $i],
|
| 193 |
'order' => $_POST['attachment_order_' . $i]
|
| 194 |
);
|
|
@@ -221,11 +225,15 @@ function attachments_get_attachments($post_id=null)
|
|
| 221 |
if( count($existing_attachments) > 0 )
|
| 222 |
{
|
| 223 |
$post_attachments = array();
|
| 224 |
-
|
|
|
|
|
|
|
|
|
|
| 225 |
foreach ($existing_attachments as $attachment)
|
| 226 |
{
|
| 227 |
array_push($post_attachments, array(
|
| 228 |
'id' => $attachment['id'],
|
|
|
|
| 229 |
'title' => $attachment['title'],
|
| 230 |
'caption' => $attachment['caption'],
|
| 231 |
'location' => $attachment['location']
|
| 1 |
<?php
|
| 2 |
/*
|
| 3 |
Plugin Name: Attachments
|
| 4 |
+
Plugin URI: http://mondaybynoon.com/wordpress-attachments/
|
| 5 |
+
Description: Attachments gives the ability to append any number of Media Library items to Pages and Posts
|
| 6 |
+
Version: 1.0.1
|
| 7 |
Author: Jonathan Christopher
|
| 8 |
Author URI: http://jchristopher.me
|
| 9 |
*/
|
| 10 |
|
|
|
|
| 11 |
/* Copyright 2009 Jonathan Christopher (email : jonathandchr@gmail.com)
|
| 12 |
|
| 13 |
This program is free software; you can redistribute it and/or modify
|
| 67 |
$existing_attachments = unserialize(get_post_meta(intval($_GET['post']), '_attachments', true));
|
| 68 |
if( count($existing_attachments) > 0 )
|
| 69 |
{
|
| 70 |
+
if( count($existing_attachments) > 1 )
|
| 71 |
+
{
|
| 72 |
+
usort($existing_attachments, "cmp");
|
| 73 |
+
}
|
| 74 |
$attachment_index = 0;
|
| 75 |
foreach ($existing_attachments as $attachment) : $attachment_index++; ?>
|
| 76 |
<li class="attachments-file">
|
| 94 |
<div class="attachments-data">
|
| 95 |
<input type="hidden" name="attachment_name_<?=$attachment_index?>" id="attachment_name_<?=$attachment_index?>" value="<?=$attachment['name']?>" />
|
| 96 |
<input type="hidden" name="attachment_location_<?=$attachment_index?>" id="attachment_location_<?=$attachment_index?>" value="<?=$attachment['location']?>" />
|
| 97 |
+
<input type="hidden" name="attachment_mime_<?=$attachment_index?>" id="attachment_mime_<?=$attachment_index?>" value="<?=$attachment['mime']?>" />
|
| 98 |
<input type="hidden" name="attachment_id_<?=$attachment_index?>" id="attachment_id_<?=$attachment_index?>" value="<?=$attachment['id']?>" />
|
| 99 |
<input type="hidden" class="attachment_order" name="attachment_order_<?=$attachment_index?>" id="attachment_order_<?=$attachment_index?>" value="<?=$attachment['order']?>" />
|
| 100 |
</div>
|
| 192 |
'caption' => $_POST['attachment_caption_' . $i],
|
| 193 |
'name' => $_POST['attachment_name_' . $i],
|
| 194 |
'location' => $_POST['attachment_location_' . $i],
|
| 195 |
+
'mime' => $_POST['attachment_mime_' . $i],
|
| 196 |
'id' => $_POST['attachment_id_' . $i],
|
| 197 |
'order' => $_POST['attachment_order_' . $i]
|
| 198 |
);
|
| 225 |
if( count($existing_attachments) > 0 )
|
| 226 |
{
|
| 227 |
$post_attachments = array();
|
| 228 |
+
if( count($existing_attachments) > 1 )
|
| 229 |
+
{
|
| 230 |
+
usort($existing_attachments, "cmp");
|
| 231 |
+
}
|
| 232 |
foreach ($existing_attachments as $attachment)
|
| 233 |
{
|
| 234 |
array_push($post_attachments, array(
|
| 235 |
'id' => $attachment['id'],
|
| 236 |
+
'mime' => $attachment['mime'],
|
| 237 |
'title' => $attachment['title'],
|
| 238 |
'caption' => $attachment['caption'],
|
| 239 |
'location' => $attachment['location']
|
js/attachments.js
CHANGED
|
@@ -74,6 +74,7 @@ jQuery(document).ready(function() {
|
|
| 74 |
|
| 75 |
attachment_name = jQuery(this).find('span.attachment-file-name').text();
|
| 76 |
attachment_location = jQuery(this).find('span.attachment-file-location').text();
|
|
|
|
| 77 |
attachment_id = jQuery(this).find('span.attachment-file-id').text();
|
| 78 |
attachment_thumbnail = jQuery(this).find('span.attachments-thumbnail').html();
|
| 79 |
|
|
@@ -87,6 +88,7 @@ jQuery(document).ready(function() {
|
|
| 87 |
new_attachments += '<div class="attachments-data">';
|
| 88 |
new_attachments += '<input type="hidden" name="attachment_name_' + attachment_index + '" id="attachment_name_' + attachment_index + '" value="' + attachment_name + '" />';
|
| 89 |
new_attachments += '<input type="hidden" name="attachment_location_' + attachment_index + '" id="attachment_location_' + attachment_index + '" value="' + attachment_location + '" />';
|
|
|
|
| 90 |
new_attachments += '<input type="hidden" name="attachment_id_' + attachment_index + '" id="attachment_id_' + attachment_index + '" value="' + attachment_id + '" />';
|
| 91 |
new_attachments += '<input type="hidden" class="attachment_order" name="attachment_order_' + attachment_index + '" id="attachment_order_' + attachment_index + '" value="' + attachment_index + '" />';
|
| 92 |
new_attachments += '</div>';
|
| 74 |
|
| 75 |
attachment_name = jQuery(this).find('span.attachment-file-name').text();
|
| 76 |
attachment_location = jQuery(this).find('span.attachment-file-location').text();
|
| 77 |
+
attachment_mime = jQuery(this).find('span.attachment-file-mime').text();
|
| 78 |
attachment_id = jQuery(this).find('span.attachment-file-id').text();
|
| 79 |
attachment_thumbnail = jQuery(this).find('span.attachments-thumbnail').html();
|
| 80 |
|
| 88 |
new_attachments += '<div class="attachments-data">';
|
| 89 |
new_attachments += '<input type="hidden" name="attachment_name_' + attachment_index + '" id="attachment_name_' + attachment_index + '" value="' + attachment_name + '" />';
|
| 90 |
new_attachments += '<input type="hidden" name="attachment_location_' + attachment_index + '" id="attachment_location_' + attachment_index + '" value="' + attachment_location + '" />';
|
| 91 |
+
new_attachments += '<input type="hidden" name="attachment_mime_' + attachment_index + '" id="attachment_mime_' + attachment_index + '" value="' + attachment_mime + '" />';
|
| 92 |
new_attachments += '<input type="hidden" name="attachment_id_' + attachment_index + '" id="attachment_id_' + attachment_index + '" value="' + attachment_id + '" />';
|
| 93 |
new_attachments += '<input type="hidden" class="attachment_order" name="attachment_order_' + attachment_index + '" id="attachment_order_' + attachment_index + '" value="' + attachment_index + '" />';
|
| 94 |
new_attachments += '</div>';
|
media.php
CHANGED
|
@@ -23,6 +23,7 @@ foreach ($attachment_files as $post)
|
|
| 23 |
echo '<span class="attachment-file-name">' . $post->post_name . '</span>';
|
| 24 |
echo '<span class="attachment-file-location">' . $post->guid . '</span>';
|
| 25 |
echo '<span class="attachment-file-id">' . $post->ID . '</span>';
|
|
|
|
| 26 |
echo '</span>';
|
| 27 |
echo '<span class="attachments-thumbnail">';
|
| 28 |
echo wp_get_attachment_image( $post->ID, array(80, 60), true );
|
|
@@ -52,6 +53,7 @@ foreach ($attachment_files as $post)
|
|
| 52 |
echo '<span class="attachment-file-name">' . $post->post_name . '</span>';
|
| 53 |
echo '<span class="attachment-file-location">' . $post->guid . '</span>';
|
| 54 |
echo '<span class="attachment-file-id">' . $post->ID . '</span>';
|
|
|
|
| 55 |
echo '</span>';
|
| 56 |
echo '<span class="attachments-thumbnail">';
|
| 57 |
echo wp_get_attachment_image( $post->ID, array(80, 60), true );
|
|
@@ -85,6 +87,7 @@ foreach ($attachment_files as $post)
|
|
| 85 |
echo '<span class="attachment-file-name">' . $post->post_name . '</span>';
|
| 86 |
echo '<span class="attachment-file-location">' . $post->guid . '</span>';
|
| 87 |
echo '<span class="attachment-file-id">' . $post->ID . '</span>';
|
|
|
|
| 88 |
echo '</span>';
|
| 89 |
echo '<span class="attachments-thumbnail">';
|
| 90 |
echo wp_get_attachment_image( $post->ID, array(80, 60), true );
|
| 23 |
echo '<span class="attachment-file-name">' . $post->post_name . '</span>';
|
| 24 |
echo '<span class="attachment-file-location">' . $post->guid . '</span>';
|
| 25 |
echo '<span class="attachment-file-id">' . $post->ID . '</span>';
|
| 26 |
+
echo '<span class="attachment-file-mime">' . $post->post_mime_type . '</span>';
|
| 27 |
echo '</span>';
|
| 28 |
echo '<span class="attachments-thumbnail">';
|
| 29 |
echo wp_get_attachment_image( $post->ID, array(80, 60), true );
|
| 53 |
echo '<span class="attachment-file-name">' . $post->post_name . '</span>';
|
| 54 |
echo '<span class="attachment-file-location">' . $post->guid . '</span>';
|
| 55 |
echo '<span class="attachment-file-id">' . $post->ID . '</span>';
|
| 56 |
+
echo '<span class="attachment-file-mime">' . $post->post_mime_type . '</span>';
|
| 57 |
echo '</span>';
|
| 58 |
echo '<span class="attachments-thumbnail">';
|
| 59 |
echo wp_get_attachment_image( $post->ID, array(80, 60), true );
|
| 87 |
echo '<span class="attachment-file-name">' . $post->post_name . '</span>';
|
| 88 |
echo '<span class="attachment-file-location">' . $post->guid . '</span>';
|
| 89 |
echo '<span class="attachment-file-id">' . $post->ID . '</span>';
|
| 90 |
+
echo '<span class="attachment-file-mime">' . $post->post_mime_type . '</span>';
|
| 91 |
echo '</span>';
|
| 92 |
echo '<span class="attachments-thumbnail">';
|
| 93 |
echo wp_get_attachment_image( $post->ID, array(80, 60), true );
|
readme.txt
CHANGED
|
@@ -2,9 +2,9 @@
|
|
| 2 |
Contributors: jchristopher
|
| 3 |
Donate link: http://mondaybynoon.com/donate/
|
| 4 |
Tags: post, page, posts, pages, images, PDF, doc, Word, image, jpg, jpeg, picture, pictures, photos, attachment
|
| 5 |
-
Requires at least: 2.8
|
| 6 |
Tested up to: 2.9
|
| 7 |
-
Stable tag: 1.0
|
| 8 |
|
| 9 |
Attachments allows you to append any number of items from your WordPress Media Library to Posts and Pages
|
| 10 |
|
|
@@ -21,25 +21,6 @@ There is a **screencast available** on the [plugin home page](http://mondaybynoo
|
|
| 21 |
1. Activate the plugin through the 'Plugins' menu in WordPress
|
| 22 |
1. Update your templates where applicable (see **Usage**)
|
| 23 |
|
| 24 |
-
== Frequently Asked Questions ==
|
| 25 |
-
|
| 26 |
-
= Attachments are not showing up in my theme =
|
| 27 |
-
|
| 28 |
-
You will need to edit your theme files where applicable. Please reference the **Usage** instructions
|
| 29 |
-
|
| 30 |
-
= Where are uploads saved? =
|
| 31 |
-
|
| 32 |
-
Attachments uses WordPress' built in Media library for uploads and storage.
|
| 33 |
-
|
| 34 |
-
== Screenshots ==
|
| 35 |
-
|
| 36 |
-
1. Screenshot coming soon
|
| 37 |
-
|
| 38 |
-
== Changelog ==
|
| 39 |
-
|
| 40 |
-
= 1.0 =
|
| 41 |
-
* First stable release
|
| 42 |
-
|
| 43 |
== Usage ==
|
| 44 |
|
| 45 |
After installing Attachments, you will need to update your template files in order to pull the data to the front end.
|
|
@@ -52,6 +33,7 @@ Firing `attachments_get_attachments()` returns an array consisting of all availa
|
|
| 52 |
* **caption** - The attachment Caption
|
| 53 |
* **id** - The WordPress assigned attachment id (for use with other WordPress media functions)
|
| 54 |
* **location** - The attachment URI
|
|
|
|
| 55 |
|
| 56 |
Here is a basic implementation:
|
| 57 |
|
|
@@ -67,9 +49,33 @@ Here is a basic implementation:
|
|
| 67 |
echo '<li>' . $attachments[$i]['caption'] . '</li>';
|
| 68 |
echo '<li>' . $attachments[$i]['id'] . '</li>';
|
| 69 |
echo '<li>' . $attachments[$i]['location'] . '</li>';
|
|
|
|
| 70 |
}
|
| 71 |
echo '</ul>';
|
| 72 |
}
|
| 73 |
?>`
|
| 74 |
|
| 75 |
-
You can elaborate on this implementation in any way you see fit.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
Contributors: jchristopher
|
| 3 |
Donate link: http://mondaybynoon.com/donate/
|
| 4 |
Tags: post, page, posts, pages, images, PDF, doc, Word, image, jpg, jpeg, picture, pictures, photos, attachment
|
| 5 |
+
Requires at least: 2.8
|
| 6 |
Tested up to: 2.9
|
| 7 |
+
Stable tag: 1.0.1
|
| 8 |
|
| 9 |
Attachments allows you to append any number of items from your WordPress Media Library to Posts and Pages
|
| 10 |
|
| 21 |
1. Activate the plugin through the 'Plugins' menu in WordPress
|
| 22 |
1. Update your templates where applicable (see **Usage**)
|
| 23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
== Usage ==
|
| 25 |
|
| 26 |
After installing Attachments, you will need to update your template files in order to pull the data to the front end.
|
| 33 |
* **caption** - The attachment Caption
|
| 34 |
* **id** - The WordPress assigned attachment id (for use with other WordPress media functions)
|
| 35 |
* **location** - The attachment URI
|
| 36 |
+
* **mime** - The attachment MIME type (as defined by WordPress)
|
| 37 |
|
| 38 |
Here is a basic implementation:
|
| 39 |
|
| 49 |
echo '<li>' . $attachments[$i]['caption'] . '</li>';
|
| 50 |
echo '<li>' . $attachments[$i]['id'] . '</li>';
|
| 51 |
echo '<li>' . $attachments[$i]['location'] . '</li>';
|
| 52 |
+
echo '<li>' . $attachments[$i]['mime'] . '</li>';
|
| 53 |
}
|
| 54 |
echo '</ul>';
|
| 55 |
}
|
| 56 |
?>`
|
| 57 |
|
| 58 |
+
You can elaborate on this implementation in any way you see fit.
|
| 59 |
+
|
| 60 |
+
== Frequently Asked Questions ==
|
| 61 |
+
|
| 62 |
+
= Attachments are not showing up in my theme =
|
| 63 |
+
|
| 64 |
+
You will need to edit your theme files where applicable. Please reference the **Usage** instructions
|
| 65 |
+
|
| 66 |
+
= Where are uploads saved? =
|
| 67 |
+
|
| 68 |
+
Attachments uses WordPress' built in Media library for uploads and storage.
|
| 69 |
+
|
| 70 |
+
== Screencast ==
|
| 71 |
+
|
| 72 |
+
There is a **screencast available** on the [plugin home page](http://mondaybynoon.com/wordpress-attachments/)
|
| 73 |
+
|
| 74 |
+
== Changelog ==
|
| 75 |
+
|
| 76 |
+
= 1.0.1 =
|
| 77 |
+
* Fixed an error when adding only one attachment
|
| 78 |
+
* Added MIME type array value (`mime`) to available attachments
|
| 79 |
+
|
| 80 |
+
= 1.0 =
|
| 81 |
+
* First stable release
|
