WordPress core function to retrieve the attachment image (object)

learn more… | top users | synonyms

0
votes
1answer
545 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 ...
1
vote
1answer
34 views

Get post attached image to display in admin dashboard

I've searched awhile for a solution on how to get the attached image in the post's editor to display within the dashboard but I am running into an issue. I've seen how to do this and can do this with ...
4
votes
1answer
55 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
16 views

Resize $term attachment using url

I'm using this plugin for attaching an image to a custom taxonomy. The plugin's function returns the attached term's image as following: function get_wp_term_image($term_id){ return get_option('...
1
vote
1answer
302 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
0answers
16 views

Getting custom image size URL in functions

I am trying to load preload-thumb into data-pil-thumb-url within the functions.php file so when a user edits a post with the TineyMCE it is automatically wrapped in a figure with the right classes. ...
0
votes
1answer
592 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
827 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
1answer
798 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 ...
1
vote
0answers
44 views

Modify 'Sizes' Attribute for Images with Specific Class

I'm ultimately trying to add useful responsive image srcset & sizes attributes to images added in a standard Text Widget. I've found this filter which does allow images to get the default WP ...
1
vote
2answers
502 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 ...
0
votes
0answers
26 views

Wordpress Image and Gallery Post format issue

This code worked and has now stopped working, for my image and gallery post format. What is wrong here? I took this code from online. Please help: function justblog_get_attachment( $num = 1 ) { $...
1
vote
1answer
57 views

Use Timber/Twig to pull an image by image ID [closed]

Is it possible to use Twig to pull an image by ID, or only to pull the post.thumbnail? The Twig docs don't seem to cover any other image need and I'd like to specify a backup image in case no post....
0
votes
1answer
556 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, tags......
0
votes
0answers
14 views

Want to display individual media file image link from get children array

In the code you can see I retrieve all the image attachments successfully, but now I want to create a link that points just to the individual attachment image and not the blogg post. Iv'e tried ...
4
votes
1answer
51 views

Validate alt text for attachments?

How can I require users to enter alt text when adding attachments? Alt text is surprisingly buried; the only way I've been able to retrieve the alt text at all is via the wp_get_attachment_image() ...
1
vote
1answer
43 views

Original image not saving?

When i'm uploading a picture, WordPress doesn't save the original image, just the thumbnails? That's why when i'm setting a featured image, the link is broken. Any help to to save the original image ...
1
vote
0answers
31 views

Get attachments for posts that belongs to a specific category

I am trying to get images which are used by a post belonging to the specific category. For example if I have plants, mushrooms and animals as post categories, I only need to retrieve images that are ...
0
votes
4answers
80 views

What can I do if I set a gif as featured image? no thumbnail when i share on facebook

My website it's for sharing content with front end post and users can post images/gifs/youtube , if a user(or me) post a gif it's directly set it to featured image and when I try to share that post it ...
1
vote
1answer
82 views

Get User's Facebook Photos as Wordpress Upload

I am new and a bit of troublesome on how Wordpress work as I have plan to use it as CMS for my commercial website. I have been figuring out on how to make an image that I have retrieved from user's ...
0
votes
1answer
477 views

Why am I getting and error from wp_get_attachment_image_src?

This Code: <div id="canvas" class="plan-page" style="background-image: url('<?php echo wp_get_attachment_image_src( stripslashes($options['sitePlan']), 'full')[0]; ?>');"></...
0
votes
2answers
187 views

Keep image EXIF info after compressing original image?

After testing I realized that Word Press after image upload will make medium and thumbnail sized images of original image without EXIF/IPTC info I realized it is because GD image library is used on ...
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 ...
0
votes
0answers
27 views

some tweak to a upload featured image code

from three days in a confusing me with this problem , i have a code for publishing a post from front end for images and video, for videos he take the thumbnail and put in featured image but for images ...
0
votes
2answers
85 views

wp_get_attachment_image not to get the post_thumbnaill

I have a setup, where I want to achieve that I have a big Picture of a product (Post-image), and then below a list of other thumbnails, which can be opened in a Lightbox. I made this, by querying the ...
1
vote
1answer
224 views

How to get category image custom post type taxonomy in wordpress?

I have a custom post estate_property and its has taxonomies property_category ,propert_action.I have installed WPCustom Category Image to upload image for each category of taxonomies. How to display ...
0
votes
2answers
509 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 class="...
0
votes
1answer
209 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
333 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
925 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
68 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
45 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
96 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
23 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 I'...
1
vote
0answers
39 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
13 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
42 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
602 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 "video-...
1
vote
1answer
70 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
127 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
124 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
73 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
9k 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
172 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
1answer
4k 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 &...
1
vote
0answers
59 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
117 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( get_post_thumbnail_id($...
0
votes
1answer
2k 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
105 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
2k 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', 'order'...