WordPress core function to retrieve the attachment image (object)

learn more… | top users | synonyms

0
votes
2answers
461 views

upload images on front by user using form

I'm using a form on my website using wordpress to allow users to create posts. It works perfectly fine, I'm abble to assign the posts to a custom post type, add Advanced Custom Fields, content, ...
0
votes
1answer
398 views

getting attachement images src and add classes

I have posts whose each contains 4 attached images. what i'm trying to do in my single.php is to get all the 4 images src to be abble to add different classes to each images. <img class="image_1 ...
0
votes
3answers
1k views

Get single image from custom fields made with WCK custom fields creator

I used WCK Custom Fields Creator to create a repeatable custom field for uploading pairs of images (one color, one black and white) to posts. So for example, one post may have three fields, with two ...
1
vote
2answers
488 views

Issue where WP Featured Image will not display

The code I'm using, is outside of WordPress i.e. define('WP_USE_THEMES', false); require('blog/wp-blog-header.php'); global $wpdb; The code that I'm trying to display the post thumbnail (the ...
2
votes
0answers
23 views

Pb with responsive image sizes in WP 4.4

I don't understand how to customize responsive sizes images in WP 4.4.1. The only available hooks that I see are wp_calculate_image_srcset and wp_calculate_image_sizes, and neither has the named ...
0
votes
1answer
490 views

Function to get custom post image URL

I have to retrieve the URL from a custom post image, just the URL, like: http://example.com/wp-content/uploads/blablba.jpg. The code which I have to filter is this: <?php cp_get_image_url(); ...
0
votes
4answers
762 views

Display Gallery Images from Custom Post Type

I want to display all the images added as gallery in a post with prettyphoto class. I am using this code. <?php /* The loop */ while ( have_posts() ) : the_post(); ...
0
votes
2answers
431 views

Unable to get wp_get_attachment_url to show

I'm trying to show a link to the full size image of an attached image. I took a code for Wordpress' Twelve Thirteen theme: <?php $metadata = wp_get_attachment_metadata(); printf( '<span ...
0
votes
1answer
22 views

Get Image Width From WP_Customize_Image_Control() File Set in WP Theme Customizer

Here's the code we're using to set an image file as an option for the site's logo via WordPress' theme customizer: /* Logo > Image -------------------------------------------------- */ ...
0
votes
1answer
742 views

Load post attached images on a single page site with fancybox

I'm trying to make a single page site that will display posts as thumbnails in some part. Then if a thumbnail is clicked, I want all the images contained in this post to be loaded with fancybox while ...
6
votes
2answers
149 views

Remove Dimension from wp_get_attachment_image

I am having some issue removing the width and height from my attachment images when using wp_get_attachment_image. This is what I am using to display the image <?php echo $image = ...
0
votes
2answers
428 views

How do I get the URL of a specific size featured image?

I am using <?php wp_get_attachment_thumb_url( $attachment_id ); ?> to get the url of a thumbnail for a post in Wordpress. However I would like to retrieve the URL of a specific size image. So ...
1
vote
1answer
25 views

How do I get a random image from subset of images in media gallery?

If a custom post does not have a featured image, I would like to grab an image from the media library to use in place of the featured image. These particular images wouldn't be attached to any ...
0
votes
1answer
24 views

Get ID for previous/next image link

For grabbing previous or next image link on attachment page we can use this https://codex.wordpress.org/Function_Reference/previous_image_link How do we get ID for that attachment? Because I would ...
0
votes
1answer
45 views

wp_get_attachment_image() not displaying post images even though wp_get_attachment_url() echo correct urls

I am trying to make a widget which takes post id as input from user and displays images of the specified post in sidebar. wp_get_attachment_url() gets me the url but in the next line ...
0
votes
1answer
19 views

Featured Image, and Image in post

I have a bit of dilemma regarding featured image. Here's my situation. I'm currently using featured image tied to a post to display on the home page, and on the single post page as well. However ...
1
vote
0answers
22 views

Adding a button to the attachment page

I have been trying to modify my theme to show an additional button on the attachment page. The reason for this is that I am using the standard wordpress gallery with a link to the attachment page. I ...
0
votes
0answers
12 views

Page is taking old removed attachment

The code given below is making the page to take all the media/attachments ever attached to the page ... even after removal of them from the page Even after I removed and left no media on page it is ...
0
votes
2answers
31 views

How do I intercept and modify the functionality of wp_get_attachment_image()?

I have a site I'm building in wordpress that has ~80GB of high resolution images, and it's exceeding my managed host's storage space. My plan is to move all the images to S3, but I noticed that ...
0
votes
1answer
399 views

Display all attached image of every post of custom post type and link to original post

I've written a loop that displays all the images that are attached to every single post of a specific post type. The post type is called "atls_events" and I'm outputting an image size called ...
1
vote
1answer
47 views

Creating page templates with image placeholders

I am creating my own theme and in the design I received for the theme I have a few pages which have 2 images of different dimensions. One is at the top (like a banner of sorts) while the other one is ...
0
votes
1answer
54 views

Trying to get custom post type attachment images to function in indexed array

I’m trying to display the first three attachment images in each post of a custom post type separately. I believe what I am looking for is a way to put the custom post type attachments into an indexed ...
0
votes
1answer
67 views

Only current gallery images with get_attached_media

On my page the gallery images are cycled and I would like to show their title as a caption. Since get_post_gallery_images only retrieves the thumbnail-url of the gallery images I have tried to use ...
0
votes
0answers
57 views

add_attachment in not working with wp_get_attachment_image_src

This code is not working add_action('add_attachment', 'example_file_added'); function example_file_added( $attachment_id ) { $attachments = wp_get_attachment_image_src($attachment_id,"medium"); ...
1
vote
2answers
6k views

get the attachement url for the medium sized image

Hi I'm using some code to create a slideshow with lytebox functionality - the following code is used in the loop to pull each image attached to a post in sequence. It seems to be only pulling the ...
0
votes
1answer
85 views

How to add image uploader to a custom widget?

I'v built a custom widget that will show some sport scores. Scores are added trough custom post. When i open new custom post(scores) i enter their team names, score, scores. Now i want to add an ...
0
votes
0answers
15 views

Get Images in Sequence in which added in post

I am trying to get images in sequence in which I put them in the post but not able to get them in sequence. The code that I added : <?php while ( have_posts() ) : the_post(); ...
0
votes
0answers
28 views

How to setup a new image size in a child theme?

I need to setup a new size for a thumbnail that will be used by a plugin but I can't get this done, this is what I have so far: /** * Registers a new image size. This means WordPress will create a * ...
0
votes
1answer
1k views

How to get image title/alt attribute?

in my wite theme, there is no alt tag configured in home slider post, i have added alt text with image from media upload. i have added below code to add / retrieve alt tag. but it display blank ...
0
votes
0answers
213 views

Create a multiple image Houzz “Save” (Share) button

I'm trying to create a somewhat smart Houzz "Save" button -- similar to a Facebook share button that allows you to pick from all of the images used on a WP post/page -- that would save the specific ...
0
votes
0answers
12 views

Get the dimensions of an embedded image

I am trying to position content based on the size of the first embedded image in a post. I am retrieving the image URL using a custom function, and then using another function to retrieve the ID of ...
0
votes
0answers
31 views

Attachment image url with size extension?

I want optimised images as I'm using them as background images. My element is 300px by 300px. I'm using the post's featured image. I've noticed when using get_the_post_thumbnail() with a specified ...
0
votes
0answers
63 views

Save the image from WP_Image_Editor

I want to save the image that shows when you click on edit image. Get the image path/name and save it like this, lets say i want to upload image.gif after upload in the same folder to have ...
1
vote
0answers
58 views

Custom thumbnail size of image when uploaded

I'm trying to make a custom thumbnail size when I upload an image only for GIFs. How do I get the image_path? list( $width, $height, $type, $attr ) = getimagesize( $image_path ); $thumbWidth = ...
0
votes
1answer
90 views

How can I set different banner images using background cover at different breakpoints?

I use the following code to see if a featured image exists and set my banner image like so: <?php if ( has_post_thumbnail() ) : $src = wp_get_attachment_image_src( ...
0
votes
1answer
1k views

Getting the image title/alt attribute from the gallery shortcode

I am trying to learn how to code php so that I can customize the image gallery within WordPress (among other customizations). The code I have works great for a stylized gallery page, but having a ...
0
votes
1answer
68 views

Get attachment images does not return any attached images

According to WP codex the code copied below will return a list of images attached to a "page". I have yet see this happen and I'm at a complete loss as to why: I have created a template page called ...
1
vote
1answer
1k views

wp_query for displaying attachments with a tag

So I am running the following query: <?php $args = new WP_Query(array( 'post_type' => 'attachment', 'posts_per_page' => -1, 'oderby' => 'title', ...
1
vote
0answers
190 views

Show image EXIF info

I am working on image gallery site. On test site (which is on shared hosting) I created and tested theme and plugins. I know that WP store some extra info about image during image upload (EXIF/IPTC ...
0
votes
0answers
56 views

Why will featured image show on some pages but not on other pages using the same template?

Why do some pages have a functioning featured image showing in the sidebar while some pages with the same template and even with the same image don't show the featured image in the sidebar but still ...
0
votes
0answers
392 views

Working with gallery shortcode and get gallery images

The only way I've been able to get the "current" gallery images from a post has been through "if has_shortcode" and checking for a gallery and getting the gallery images. In this way the client can ...
1
vote
1answer
274 views

Understanding and altering the structure of posted images

Currently this is the (default) Wordpress image output: Float left, with caption, link to img <figure id="attachment_10220" style="width: 167px;" class="wp-caption alignleft"> <a ...
0
votes
3answers
5k views

How do I change/modify the_post_thumbnail(); html output?

I'm working on building out a custom theme and have been struggling with this one for a bit. I am trying to modify the HTML output of the_post_thumbnail(); function. I need to do this because I am ...
0
votes
0answers
19 views

Why WordPress attachments LINK TO settings are not working?

Using this code below, I added some on-hover share icons for all images of the content. But, now these images are not getting any "Link To" setting from authors. I don't know what is the problem. Can ...
0
votes
1answer
113 views

Hide Image Container if No Image Attachments

I have a CPT that displays any attached images via a slider. However, when there are no attached images the slider still appears. Is there a way to add a conditional IF statement that will hide the ...
0
votes
1answer
71 views

Get attachment/image info in JS

Is there a specific method to get attachment/image info in JS? I have an attachment id and before I use any add_action("wp_ajax_get_image_info", "get_image_info"); I would like to see if there is ...
1
vote
1answer
1k views

wp_get_attachment_image() not working when trying to add with and height attributes

I am using wp_get_attachment_image() to try and output an img tag with width and height attributes. Here is my code: $thumb_src = wp_get_attachment_image( $id, 'thumbnail', false, array('width'=> ...
3
votes
1answer
688 views

Having Problem On Getting WP Post Gallery Images URL

I need to get the URL (actual Size) of all images of gallery associated with a post in single.php. The following code from Codex returns all images in very small size 150x150 which is not suitable for ...
0
votes
0answers
55 views

Issue on Getting WP Gallery Items In cpt-single.php As Attachments

Having a "Custom Post Type" called Projects I am trying to get actual URL of images added into Post Gallery and list them in class other than WordPress built in .gallery. This is the code which I ...
0
votes
2answers
110 views

Setting featured image based on related post

I am using a plugin called The Events Calendar. I don't always set the featured image for each individual event. Each event has an organizer ID (tribe_get_organizer_id). I want to add a filter that ...