WordPress core function to retrieve the attachment image (object)

learn more… | top users | synonyms

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
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 -------------------------------------------------- */ ...
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 = ...
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
23 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 ...
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
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
1answer
55 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
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"); ...
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
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
214 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
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
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 ...
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 ...
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
275 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
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 ...
0
votes
2answers
430 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 ...
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(); ...
3
votes
1answer
691 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
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
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 ...
0
votes
1answer
407 views

Display custom gallery in each wordpress post

In my website there is post thumbnail slider. Post thumbnail slider will show images related with blog post. I want when we write any post then it will allow me to upload few images via media uploader ...
0
votes
1answer
400 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 ...
5
votes
2answers
435 views

Check if post has attachments (not image)

Need to do a check if post has attachments that are not images. I haven't seen this anywhere - thoughts?
0
votes
0answers
221 views

Change default URL of image attachment

I have only one image attachment per post, as featured image. Every post have just one image, featured image, and no any other image in post content. By default URL of image attachment is: ...
0
votes
1answer
118 views

Why this thumbnail hard crop code does not work?

I am trying to show thumbnail image as an attachment in the feed. So I use following code. function add_images_to_rss($var) { global $post; if(has_post_thumbnail($post->ID)) { ...
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
0answers
36 views

Add the title of an image to the image link into a post

i have a simple question. I have a page of wordpress site where i have insert image that link to "file media". I use shodwobox.js plugin to display the images. i have use this code to add ...
1
vote
1answer
305 views

Set the background to a default image if there isn't a specified “featured image”

I am having a little trouble displaying a default image as a background image when a feature image is not present. This is the code I am using <?php if (has_post_thumbnail( $post->ID ) ): ...
0
votes
1answer
1k views

wp_get_attachment_image_src() returning incorrect width and height [duplicate]

I am trying to return the src, width and height of a cetain image: $img = wp_get_attachment_image_src(get_post_thumbnail_id(), 'large'); This is returning the expected array but with incorrect ...
1
vote
1answer
172 views

How to add an image for unit testing?

I have to test the function where it calls wp_get_attachment_image_src. How do I add an image for testing, because right now if I call this method it returns false.
0
votes
1answer
603 views

Making images from single.php pointing to an attachment .php template

I am trying to make the inserted images from a post (single.php) to point to (single-attachement.php) an attachment page. So far I checked a post here on stackexchange and added this code on the top, ...