Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [wp-get-attachment-image]

WordPress core function to retrieve the attachment image (object)

0
votes
0answers
9 views

Get custom image size for image send to editor

I have been trying to this right but it seems i just can't. I want to get a custom image size for any image added to the editor. Here is my code: ` add_filter( 'image_send_to_editor', '...
1
vote
1answer
21 views

How check that there is post thumbnail feature image or not on wordpress?

On my wordpress site , I have some post that all of them have post thumbnail, but their post thumbnail removed from host and now when i want to load them on site , there is no image for loading to ...
0
votes
2answers
37 views

trying to get wp_get_attachment_url to output clickable link

be gentle, I'm pretty new (just over from Joomla). This is part of an array... echo '<tr><th>' . esc_html( $item_1_title ) . '</th><td>' . esc_url( wp_get_attachment_url($row[...
0
votes
0answers
31 views

Filter not applied to all image sizes

I have a callback applied to wp_get_attachment_image_attributes to add attributes to the generated image html. function add_lazyload_to_attachment_image($attr, $attachment) { if (strpos($attr['...
0
votes
1answer
37 views

WordPress Iframe for blog image

I would like to have an Instagram feed for featured image of the blog. Already I have Instagram feed blog post but I would like it to be also on featured image. Any idea how to achieve this? Link ...
0
votes
2answers
277 views

Get image url using image id

I was looking for a solution to get the image url starting from the uploaded media id. I'm using a custom field to specify which images to show on a post page. Then I retrieve the images ids with the ...
0
votes
1answer
35 views

How to get image ID based on get_theme_mod image URL?

I'm trying to use wp_get_attachment_image function to insert image. For that I need use image ID. So now I need to know how to get this ID by image URL taken from get_theme_mod from WP Customization ...
0
votes
4answers
287 views

How to add css class to a specific set of images?

I am trying to understand how to add a class to a set of images in WordPress. Specifically I am trying to add a class, for example, .no-lazy-load, to exclude those images from being lazy loaded via ...
0
votes
1answer
97 views

wp_get_attachment_image_attributes not working

I move all images to a subdomain.after that there is a problem to show some pictures which have srcset. for the home page, I resolve the problem with the below code function alter_image_src($attr) { ...
0
votes
0answers
16 views

Using the_post_thumbnail do not rollback to original image if specified thumbnail does not exist

We have a series of posts some do not have a defined thumbnail size (i.e. "small-featured"). Right now with the_post_thumbnail() if WordPress can not find that size it replaces it with the original ...
0
votes
0answers
428 views

How to get featured image in Gutenberg from a transition_post_status hook?

Before the WordPress 5.0 update, I was able to get the featured image URL from a transition_post_status hook, for posts that are just published, from the WordPress post editor (but not from Gutenberg)....
0
votes
0answers
24 views

Filter posts with tags of the attachment?

Is there anyway I can filter posts with the tags of the attachment? I'm pretty new to wordpress. Current arry: $args = array( 'post_type' => 'post', 'post_parent' => $post->ID, '...
0
votes
0answers
23 views

wp_get_attachment_image_src calling wrong location

We are using the Exopite Simple Options Framework framework in our plugin. One of the fields is an image upload metabox: This works fine and images are uploaded and attached to the post as expected....
0
votes
0answers
17 views

How to get attachments urls if text match?

Is there any plugin or code that can help me in this. I want to fetch images that have to include text in their file name that I mention on my page or in code. I mean I want to display all images if ...
1
vote
1answer
48 views

How to get next image with this code from same post?

I want to show images in my single-content.php file. I have almost 20 to 25 images in every post. I want to print them with below code one by one. I have to change one line in code for every image for ...
0
votes
1answer
46 views

limit amount of photos uploaded per cpt post

On my site I have a front end form for users to create a post and upload images. It works fine however I cant seem to figure out how to limit the number of images per post. The image attachments get ...
0
votes
1answer
43 views

WordPress Betheme: Unkown subheader image of a child page

I want to get the URL of the Muffin Betheme subheader image of a child page, in the parent one, for each of its children. Thus, I go through the children, then I try to get the subheader image for ...
0
votes
1answer
49 views

Get attachment URL from attachment Link in WordPress

I have been trying to fetch the URL of image attachments ( e.g. - http:// localhost/mytheme/post-format-gallery/100_5478.jpg ) using their attachment links ( e.g. - http:// localhost/mytheme/post-...
0
votes
1answer
62 views

copy images from custom field to another custom field

On my wordpress site I have a front end form that allows users to create posts and upload photos for a custom post type 'Property'. Using the following function - $property_sights_value = ...
2
votes
1answer
322 views

Force all images to full size in page template

I have a page template that outputs all posts with minimal formatting - no headers, footers, sidebars, etc. With the loop, the_content() is used to output content (text and images). I need to ...
3
votes
1answer
40 views

Display Single Attachment Image file size, uploaded date, resolution, file-name etc in Sidebar

Sorry for any wrong details. I am totally new to WordPress development. I am running a photo site. On single attachment page, I want to show the details (i.e upload date, filename, size, resolution) ...
1
vote
0answers
34 views

Contact Form 7 Get Image Function [closed]

I am building our website and we are a business that sells dresses. I am looking to have an "Inquire" button for every dress that we have (we avoid posting prices). My dilemma is that a regular ...
0
votes
0answers
32 views

Fetch customizer image and output as an inline css style background image

So I have a feeling this is quite simple, but Im a bone head since I'm still learning PHP as I hack away at themes via my own child-theming... In short, I've built a customizer section in my ...
0
votes
0answers
302 views

wp_get_attachment_image_url not returning correct url for custom size set

I'm trying to retrieve all image urls uploaded to a single post and store these in an array so I can access them within my document. I'm using the advanced custom fields plugin to upload images too ...
2
votes
1answer
1k views

Change wp_get_attachment_image attributes (src and srcset) on specific custom field

I'm using ACF to output images in an image carousel called Flickity. Flickity supports image srcset with lazy loading. Here's my basic ACF markup which uses wp_get_attachment_image: <?php $...
1
vote
1answer
112 views

wp_get_attachment_image_src returns the wrong image

I uploaded an image my-image.jpg of dimension 1280x854, after that, I went to Dashboard > Media to crop it to 854x854. (Apply changes to All Image Sizes.) This however only change its thumbnail in ...
0
votes
0answers
27 views

How to find the largest images in wordpress post

I have wordpress post with multiple images which are of multiple sizes. I need to find the largest image from the images in the post & set it as featured image. I know there are plugin that ...
2
votes
1answer
978 views

How to get CMB2 to show a single image at a specific size

Trying to get the CMB2 plugin to display an image at the WP default medium size on the page. I can get it to display an image but that image could be any size the user wants I'd rather it was cropped ...
1
vote
1answer
353 views

how to link post-thumbnail to original img in a lightbox?

I have a page showing custom post type, but I don't know how to link to the full size image that can be opened by a lightbox plugin. the post page is like: <div class="content" id="main-content"...
1
vote
1answer
40 views

Get attachments from a post

I created a snippet to get all attachment from a post, included attachments from comments. <?php $post_attachments = get_posts( array ( 'post_type' => 'attachment', 'posts_per_page' =&...
0
votes
0answers
177 views

How to inject alt and title attributes for every image in each post into HTML?

My sincere apologies if the following is completely way off as I'm new to this. This previous answer looks like what I'm trying to find, but I'm not sure what to do with this information. From what ...
0
votes
1answer
147 views

wp_get_attachment_image_src on multisite

I try to get cropped image src on my subdomain multisite, but not working. My code here: // avatar uploader $wp_customize->add_setting( 'bwpy_logo2', array( 'sanitize_callback' => 'absint', ...
0
votes
1answer
713 views

set title attribute in wp_get_attachment_image()

I am trying to use wp_get_attachment_image() and set a different title attribute from what is stored in the media library for that image. echo wp_get_attachment_image($image_id, 'large', false, array ...
-5
votes
1answer
265 views

Function to convert image id to image name or image url

I was working on a clients site, and he has a website which is using Mycity theme and geocity plugin for importing places from google in directory website. Now he wants me to export places post type ...
1
vote
2answers
487 views

ACF Plugin - Random Gallery Image with wp_get_attachment_image()

I’ve found others (source 1, source 2, source 3) using the following code for displaying a random gallery image (and it works) with the ACF Plugin: <?php $gallery = get_field('images'); $rand = ...
-1
votes
1answer
243 views

Show Taxonomy Child Terms (name and image) on Parent Term Page

I am trying to show respective child taxonomy term names and images on their parent term pages. For example: Parent Term A Child Term 1a Child Term 2a Child Term 3a On the Parent Term A taxonomy ...
0
votes
3answers
172 views

Display attached images as background-image css

I have an issue here and i hope you guys help me because i'm getting crazy. Anyway, as you know wordpress output the attached images in tag. I need them as background-image css. Here's my code; ...
0
votes
1answer
34 views

get_children returns older images

I am listing all attached images to published posts & pages, however older/removed attached images are being listed. I wonder if this depends on revisions (that shouldn't be considered at all) ...
2
votes
0answers
208 views

Issue to get wp_get_attachment_image with cmb2

I have a problem get the image with cmb2, I have tried in many ways without successm according to the documentation, this is fine, what can I be doing wrong? add_action( 'cmb2_admin_init', '...
0
votes
2answers
483 views

Images uploaded on frontend display correctly but not in media editor.

if ($_FILES) { $uploaddir = wp_upload_dir(); $file = $_FILES[featured_image]; $uploadfile = $uploaddir['path'] . '/' . basename( $file['name'] ); ...
0
votes
1answer
340 views

Multi Photo Upload with Caption on Front End for Custom Post Type

I have a page template that allows users to create posts (for a custom post type) on the front end and upload (multiple) images. Currently it works fine but I would like to enhance it by adding the ...
1
vote
1answer
2k views

How do I add an image upload, custom field to a WooCommerce product?

For each WooCommerce product, I want to use a unique background in the theme. The simplest way I can think of doing this is by using a Custom Field for each WooCommerce product, with the value being ...
0
votes
1answer
106 views

Creating custom setting in add media popup

I am creating a checkbox in the Add Media popup screen to add HTML to the $html output when inserting an image. This is working fine. However, once I have added an image with the checkbox selected. ...
0
votes
2answers
3k views

How do you get the full size url of an attachment image

I do not see a way to get the URL to the full sized image of an attachment. Yes, i can use get_the_post_thumbnail_url($post->ID, 'full'), but that is of no help if the image is not the featured ...
0
votes
1answer
1k views

How to loop through all the attached images in a post, and get their url one by one

On a single post page, I would like to get the url of the attached images one by one. For example: I uploaded 5 images in my post from the dashboard. On the single page I want each of their url, like ...
0
votes
3answers
722 views

How to get full absolute url for post attachment?

I'm trying to manually fill the Open Graph tags and I'm having some troubles in setting the content for the og:image tag. In a single post page, I set it this way: <?php $thumbnailSrc = ...
0
votes
1answer
1k views

Change Image URL to a CDN

Running NGINX, Wordpress 4.75 after upgrading from a way older version of Wordpress, our images are being served locally and I would like to change that to our CDN. In the past images that were ...
3
votes
1answer
298 views

How to crop image from image src in a specific size

I got the image src from user input by a metabox field. Now I want to render this image in a specific size. Just as like WordPress image cropping in a specific size. I tried to get the image ID from ...
3
votes
1answer
2k views

Why is wp_get_attachment_image not including “full” size in srcset?

I am trying to get an image with it's srcset attribute for all the image sizes using wp_get_attachment_image(). But it seems like the "full" (original) size is not listed: <?php echo ...
0
votes
1answer
35 views

Google verification challenge with file location

Our team lost access to our Google Analytics account and the only way we can get it back is by inserting a text file into our website. However, the link for uploading files is something like www....