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 tried the answer posted by Robin I Knight upload-post-thumbnail-from-the-front-end. Sadly i couldn’t get it to work. Is there … Read more

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 value=””>Select</option> <?php $args = array( ‘numberposts’ => -1, ‘orderby’ => ‘menu_order’, ‘order’ => ‘ASC’, ‘post_type’ => ‘attachment’, ‘post_parent’ => $post->ID, ‘post_mime_type’ => ‘image’ ); $image = get_posts($args); if($image) { foreach($image as $key => $data) : ?> <option value=”<?php echo … Read more

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 4 This will allow you to rename an attachment as soon as its uploaded: add_action(‘add_attachment’, ‘rename_attachment’); function rename_attachment($post_ID){ $file = get_attached_file($post_ID); $path = pathinfo($file); //dirname = File Path //basename = Filename.Extension //extension … Read more

Get the first image from post content (eg.: hotlinked images)

I am using this code directly from the codex. function echo_first_image ($postID) { $args = array( ‘numberposts’ => 1, ‘order’=> ‘ASC’, ‘post_mime_type’ => ‘image’, ‘post_parent’ => $postID, ‘post_status’ => null, ‘post_type’ => ‘attachment’ ); $attachments = get_children( $args ); //print_r($attachments); if ($attachments) { foreach($attachments as $attachment) { $image_attributes = wp_get_attachment_image_src( $attachment->ID, ‘thumbnail’ ) ? wp_get_attachment_image_src( … Read more

how to get original image using wp_get_attachment_image_src

I want to get the original image with the same width and height as uploaded. My original image is 630*370. Using the following function call I get a thumbnail sized at 630*198. wp_get_attachment_image_src($PriImgId,array(‘630′,’370’)); How can I get it at 630*370 3 Try this : wp_get_attachment_image_src( $PriImgId, ‘full’ ); Also, for more options see the Codex.

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 using an instantiation of the wpdb class. However, there are a couple of thousand images which we would like to … Read more

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, and it doesn’t require you to use the horrible thickbox media uploader built into WP. I hate that … Read more

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 attachments to a specific page that only exists to contain these images. I’m wondering if it’s feasible to store these in … Read more

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() { register_taxonomy_for_object_type(‘category’, ‘attachment’); } This works and adds a simple text field for Category to the Media page when viewing an image. What I really want is to make it … Read more