WordPress core function to retrieve the attachment image (object)

learn more… | top users | synonyms

0
votes
1answer
50 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
10 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
18 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
88 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
9 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
12 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
68 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
37 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
55 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
52 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
35 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
454 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
88 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
43 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
154 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
168 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
16 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
67 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
47 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
109 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
287 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
0answers
317 views

Previous and next posts with images on attachment page (image.php)?

Show two previous, current and two next posts with post featured images and links to previous and next post on attachment (image.php) page? I have image gallery site and that kind of navigation is ...
1
vote
1answer
404 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
47 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
230 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
82 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
0answers
174 views

Changing attachment url?

How to change default attachment url: www.domain.com/category-name/subcategory-name/some-post-title-here/attachment/some-post-title to: ...
0
votes
1answer
260 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
225 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 ...
4
votes
2answers
286 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
143 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
0answers
89 views

Filter wp_get_attachment_image

I'm working on a new WordPress plugin, that will have to change the media library directly. For that I have to overwrite or filter the wp_get_attachment_image function, that class-wp-media-list-table ...
0
votes
1answer
90 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
358 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
32 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 ...
0
votes
0answers
107 views

Special characters in image url stripped out with wp_get_attachment_url

I've got a plugin I'm working on and I need to access an attachment image. I've been using either wp_get_attachment_url() or wp_get_attachment_image_src() to get the slug for the image. It's been ...
1
vote
1answer
153 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
722 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
92 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
454 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, ...
0
votes
0answers
35 views

Adding Image input to a plugin post

Here is my problem. I have a plugin running in my wordpress site that posts a person biography. It is designed so that the image for the biography is inserted with the content. I want a specific ...
0
votes
1answer
236 views

echo image caption

I am attempting to echo out my image captions in a Bootstrap Carousel. I have managed to get my images to display but unable to display my captions. I have attempted to use wp_get_attachment_metadata ...
0
votes
1answer
57 views

Open image size links in a page instead of direct image link

I am using this custom function to display image sizes on image.php (attachment page) function my_get_image_size_links() { /* If not viewing an image attachment page, return. */ if ( ...
0
votes
0answers
190 views

wp_get_attachment_url returns wrong file name

I just spent the past hour trying to find a topic relating to this. I must be doing something really stupid and I don't know what it is. Basically, my problem is that, after being uploaded, images ...
0
votes
1answer
167 views

wp_get_attachment_image_src always returns false

I'm using wp_get_attachment_image_src to retrieve image URL. Codex is simple for this function and starting from an ID on my database I used wp_get_attachment_image_src in this way: $image_url = ...
0
votes
0answers
59 views

unable to access image attributes in wp_postmeta when looping through posts

I have an issue with accessing attributes of a library image, particularly the "Alternate Text" attribute. I use the ACF (Advanced Custom Fields) plugin to pull back the slideshow image which is ...
0
votes
2answers
289 views

Multiple instances of Featured Image Thumbnail As A Background On Homepage

Here's what I'm trying to do: Make it so the first 6 posts are displayed differently on the homepage than posts 7 and on. The first six posts should grab their featured thumbnail images and use them ...
3
votes
1answer
990 views

How to add a “data-” attribute to the image tag of native gallery output

While trying to make WordPress and Galleria to become friends I already have a good result. Galleria can easily be used to display native WordPress Galleries. I'm using a plugin but that's not ...
1
vote
0answers
102 views

frontend image post uploader

I've set up image uploader on front end custom form for users with some text input, textareas etc .Everything works fine, untill I decide don't upload any image. Then my "thank you" page gets blank. ...
1
vote
1answer
600 views

How to get media objects

I am busy with a loop to return all media in the medialibrary in objects. I figured out how to get the images ( with wp_get_attachment_image('$mediaID') where the $mediaID is the id of the image ) ...