The attachments tag has no wiki summary.
15
votes
2answers
2k views
How to manage attachment relationships for specific posts in WP 3.5+
In WordPress 3.5, media management has changed entirely. Also, relating attachments to specific posts is (I believe) basically only being done for backward compatibility. Therefore, after uploading ...
12
votes
2answers
4k views
Creating an Image-Centric Custom Post Type?
Does anyone have any tips for creating an image-centric custom post type?
To elaborate, my blog has rotating header images, shown below:
The two images in the top left are randomized, and exist as ...
10
votes
2answers
13k views
How To Retrieve An Image Attachment's Alt Text?
I am using an attachment.php file to show large versions of images that have been clicked on elsewhere. I'd like to pull the image alt text as a caption under the image with javascript, but the alt ...
10
votes
5answers
4k views
Can I add a Category Metabox to attachment?
I am using register_taxonomy_for_object_type() to add the Category taxonomy field to Media uploads (attachments). I'm using this code to do so:
add_action('init', 'reg_tax');
function reg_tax() {
...
9
votes
2answers
2k views
Turn a URL into an Attachment / Post ID
Is there any way I can take a URL of an image and find the attachment or post id of that image in the database?
Here is the situation:
I'm in a loop going over all the 'img' tags that are surrounded ...
7
votes
3answers
3k views
Can I attach image to post without adding it to post?
another question about image.
Can I add/attach images to post without adding it to post? The reason behind this is so that I can manipulate it whatever I want using API.
7
votes
3answers
2k views
Broken? WP_Query and “attachment” as a post type
I have a gallery attached to a page. On that page, I'm running the following query:
$events_gallery = new WP_Query( // Start a new query for our videos
array(
'post_parent' => $post->ID, // ...
7
votes
2answers
3k views
How does WP media uploader create the 3 different sized images, and how can I duplicate it
I have finally!! got this thing I've tried about 12 times to make and 12 different ways, but finally got it to work,... sort of.
I made a custom metabox for uploading and attaching images to posts, ...
6
votes
3answers
6k views
How do I get the size of an attachment file?
I'm using the following template code to display attachment links:
$args = array(
'post_type' => 'attachment',
'numberposts' => -1,
'post_status' => null,
'post_parent' => ...
6
votes
3answers
11k views
Submit post and upload image from front-end
I am trying to do something similar to the above question. I am trying to make users post and upload images from front-end. I have already done the post form and its working.
I just followed and ...
5
votes
1answer
1k views
Programmatically get images by URL and save in uploads folder
I am involved in a large migration from another CMS to WordPress. We have a copy of the database and have worked out how to extract the content and programmatically create WordPress posts from it ...
5
votes
2answers
710 views
How it is possible to use taxonomies on attachments?
With WordPress 3.5 was changed the media management and edit screen use the default of edit post type UI. The taxonomies is very usefull for WP installs, there have different users and attachment to ...
5
votes
2answers
4k views
Attaching media to custom posts without editor
I'm creating a custom post type, "gallery", in which the admin should be able to upload images (these images would be attached to the post).
The thing is that the "editor" meta box is disabled for ...
5
votes
1answer
2k views
Put the media uploader in a metabox
I find it very unnecessary to have an "add image" button that brings me to yet another screen that will let me upload content to my post.
Ideally I would like to have a meta box with the option to ...
5
votes
2answers
975 views
Expanding new Media Uploader in WordPress 3.5
In current version of WordPress it is quite easy to expand the attachments fields using attachment_fields_to_edit filter, but in latest WordPress 3.5 RC2 it's not working. We can expand it using ...
5
votes
1answer
1k views
Trying to hide buttons from Attachment window
To simplify the Media Library layout to users when uploading an image, sometimes i hide the following fields:
function myAttachmentFields($form_fields, $post) {
if ( ...
5
votes
2answers
608 views
Are captions stored anywhere?
In regards to my previous question about shortcode captions, it doesn't appear to me that the actual text of a caption is stored anywhere other than in the post content within the shortcode itself.
I ...
5
votes
1answer
90 views
Remove duplicate attachments
Here is the situation:
I have an automated script that upload attachments and link each attachment to a specific post. By mistake, the script run multiple times and I have the following
More than ...
5
votes
1answer
295 views
Edit image / Delete image link
There is a function in Wordpress that allows to display a "edit post" link if the user has sufficient rights.
<?php edit_post_link( __( 'Edit' ), '<small class="edit-link">', ...
4
votes
2answers
762 views
Delete original image - keep thumbnail?
I'm using a lot of thumbnails but never the original file. To save space, I'd like to prevent the original from being saved on disk but only keep a thumbnail of 100px. How can I do this?
Thanks,
...
4
votes
5answers
4k views
Disable image attachment links
Is there a way to disable image attachment links trought a filter in functions.php or something ? I know it's possible to do it manually when you add an image to a post but I want to disable this ...
4
votes
1answer
4k views
How to get attachment file name not attachment URL
I'm using this code to list the image attachments of a post:
<select name="chb_homes_for_sale_specifics_floor_plan" style="width:100%;">
<option ...
4
votes
2answers
660 views
How to cleanly delete attachment but retain original file?
wp_delete_attachment() is very comprehensive and wipes every trace of attachment from database and disk.
Is there easy way to keep original file? Forking under another name is not an option, because ...
4
votes
1answer
2k views
Changing attachment urls?
How can I change the format of attachment page urls from /[post-url]/[attachment-name]/ to /media/[attachment-name]/? I understand that I can override the output of get_attachment_link via the ...
4
votes
1answer
430 views
explode array within shortcode
This functions at the moment but it only returns the first value from the array. I've been struggling to echo, print, explode, or whatever the multiple custom field values that share the same key ...
4
votes
2answers
361 views
How to get attachments for a specific post type?
I have this page where I am showing all post's attachments.
This is the code:
<?php
$args = array(
'post_type' => 'attachment',
'post_status' => 'published',
'posts_per_page' ...
3
votes
1answer
6k views
Get all post attachments except featured image
$args = array(
'post_type' => 'attachment',
'numberposts' => null,
'post_status' => null,
'post_parent' => $post->ID
);
$attachments = get_posts($args);
if ...
3
votes
3answers
2k views
Getting Path To Uploaded Attachment Image After Upload
After you have uploaded an attachment in Wordpress using the media upload screen, is there a hook or filter I can run after the image has been uploaded where I can get the path to the uploaded image ...
3
votes
1answer
138 views
Show Post ID in “Find Posts or Pages” box in Media Library?
In the Media Library, when I go in to attach a media item to a post, I know I can use "Attach" to pull up the "Find Posts or Pages" pop up.
This brings the following list of post title, date and ...
3
votes
4answers
3k views
custom fields for attachments?
is it possible to add extra fields via the functions.php script for attachments in wordpress?
Tried loads of examples but none seem to work. Worried an existing plugin might be affecting my attempts ...
3
votes
1answer
652 views
Remove “From computer” media tab for posts with existing attachments?
On editing the attachments of a post whith at least one attachment previously uploaded, how do I remove the From computer tab and redirect to the Gallery tab?
This is my current code:
...
3
votes
1answer
2k views
media_sideload_image generates blank?
I'm creating a custom post form that is supposed to take an external image and uploads it to the media library and attach it to that post. This should be possible by using media_sideload_image, but ...
3
votes
2answers
688 views
Function to call the attachment image from post
Hey everyone, I can't se the image of the post (it is attached through gravity form as a post-image) with this function I see the missing image icon with the title and the working link but no ...
3
votes
2answers
1k views
Automatic image renaming based on title
Is there a plugin or a "hack" that can help me do this? I have spent hours try to figure this out so I would greatly appreciate nay help. I have WP 3.1 running php5 Thanks!
eg.: ...
3
votes
1answer
2k views
remove links from images using functions.php
I am looking for a way to remove the attachment link from images in the post content.
I would like to add this to the functions.php in my theme. I know you can disable this in the post on a per ...
3
votes
2answers
400 views
how to test for attached image
I am trying to find out whether or not a post has images. If it does, I then want to know if a featured image was specified for the thumbnail - if not, the get_thumb() function will assign an image ...
3
votes
1answer
180 views
On Multisite: Loop to Show First Four Images of Recent Posts Across Network
I would like to display the first four images from posts across a WordPress network.
In Otto's image gallery tutorial he recommended using the following to get images from recent posts. Query ...
3
votes
3answers
1k views
Can I attach a document (eg: PDF) but have a JPEG as a thumbnail?
Is there a built-in feature or plugin that allows you to attach a document to a post or page such that the actual attachment file is one thing (eg a PDF) but the thumbnail images are another (eg a ...
3
votes
1answer
96 views
get post attachments of a particular size
Is there a good way to know if a post has an image attachment of a particular size? I'm trying to fetch 5 random posts, but I only want results that have image attachments with a (custom) size of ...
3
votes
1answer
93 views
WordPress comment count to include attachment comments
How can I make the comment count on a post on my index page include comments that have been made on, in my case, individual gallery pictures that are included in the post? It seems that comments made ...
2
votes
4answers
1k views
Change attachment filename
Is there a function that allows me to change the filename of an attachment, based on the Attachment ID I have?
Thanks!
Dennis
2
votes
4answers
3k views
using upload image with media_handle_upload .. but !
I'm tring to upload image in wordpress by using some function ..
I found the way to upload images but there are one problem ..
when the user upload his image , wordpress create more than one image ...
2
votes
4answers
3k views
How to restrict access to uploaded files?
I have a restricted area on a website that can only be accessed by logged in users. Fot that I created a page template with a 'current_user_can()' condition.
My problem is that the documents attached ...
2
votes
3answers
1k views
Get first image in a post
I am using this code directly from the codex.
function echo_first_image ($postID)
{
$args = array(
'numberposts' => 1,
'order'=> 'ASC',
'post_mime_type' ...
2
votes
1answer
584 views
Doubled titles when using All in One SEO with custom template
I created a separate template, attachment.php, for displaying image attachments. It's relatively simple; basically a stripped down version of single.php. Everything is working great except that when ...
2
votes
2answers
2k views
Add_Filter example for wp_get_attachment_link
Let me preface by saying I don't really understand Add_Filter, but I think that I want to be using it here. If not please let me know.
I want to modify wp_get_attachment_link so that the link url ...
2
votes
3answers
506 views
How can you determine whether an image is merely attached or has actually been inserted into a post?
Bear with me. I promise there's a question when I'm done :)
In WordPress, you can upload images while editing a post and have the option to insert them into the content (or not).
Regardless, the ...
2
votes
1answer
155 views
query attachments of parent page if attachments of current page are smaller than …
I'm using WPQuery and get_children($query_images_args) to query attachments from the current page. If the current page has no attachments assigned I'm querying the images of the parent page.
This ...
2
votes
3answers
171 views
Limit amount of results returned
How can I limit the amount of results returned?
$images = $wpdb->get_col("
SELECT ID FROM $wpdb->posts
WHERE post_type = 'attachment'
AND ID in ($meta)
ORDER BY menu_order ASC
...
2
votes
1answer
944 views
get_the_post_thumbnail() doesn't taking style attribute
This seems to be an easy one but its giving me quite a hard time. get_the_post_thumbnail() suppose to take attribute as an array. Well, everything working right but when i pass style attr its doesn't ...