Visual Composer adds the image ID to the generated shortcode. This gives you more flexibility with image sizes. You can use it like this:
$imageSrc = wp_get_attachment_image_src($image_url, 'thumbnail');
if( $imageSrc ) {
echo '<img src="' . $imageSrc[0] . '" />';
}
The thumbnail
param could be replaced by medium
or another valid image size. The if
clause is there to verify that the image is really there (not deleted).
Advice: Rename the param_name
to image_id
so you won’t get confused when using the code later.
Source: https://developer.wordpress.org/reference/functions/wp_get_attachment_image_src/
Related Posts:
- Remove images from get_the_excerpt
- Need to convert image url to a Base_64 data url with wordpress function..
- Missing feature image link function
- Solution to render Shortcodes in Admin Editor
- Add image size if page template
- Use AJAX in shortcode
- Set JPEG compression for specific custom image sizes
- remove links from images using functions.php
- Include PHP file in Content using [shortcode]
- Issue with wp_get_attachment_image() and SVG file type
- How to change the markup WordPress inserts for post images
- Programmatically Set First Image as Featured
- Removing default image size list in Media Box
- Shortcode producing headers already sent error
- How to add attributes to a shortcode
- How to use get_template_directory_uri() to load an image that is in a sub-folder of my theme?
- WP 4.4. responsive loads normal image after loading the responsive image
- How to display random users with avatars
- How to add classes to images based on their categories?
- How to create thumbnails for PDF uploads?
- Enabling shortcodes for custom fields
- How to reduce original image quality on upload?
- How to use get_media_embedded_in_content function
- Is it possible to maintain image aspect ratio when scaling images?
- Can shortcodes contain conditional statements? Even without them my shortcode renders blank page
- Shortcode with parameters inside parameters
- Auto delete WordPress images/thumbnails (all sizes) and featured after X days/hours, or similar?
- Creating a table from shortcode avoiding wpautop for each row
- Set image size on media and text block with a function
- Generating Responsive Background Image Sizes in PHP
- Changing a function in function.php to a shortcode – for listing categories of only a certain post type
- Stripping shortcode from custom excerpt function
- Why are image thumbnails cropped proportionally (not per dimensions)?
- how to create shortcode in wordpress
- What is wrong with this Shortcode? I get it in a wrong place inside the content
- Display random text from a file with the WP built-in AJAX API
- Set first oembed in post to a global variable or function
- Formatting post content to exclude gallery
- Create thumbnail on PDF upload with Gravity Forms
- Gallery images titles – get from post
- Shortcode with custom content attribute?
- Problem with extract() with custom shortcode
- Use Exact Image Size using add_image_size
- Shortcode to insert menu in page body?
- How to add a rel attribute to images that contains their categories?
- Using locate-template & shortcodes doesn’t appear to work
- Displaying a random user with a shortcode
- Why are image thumbnails cropped proportionally (not per dimensions)?
- Passing HTML in WordPress Shortcode arguments
- Adding body class when post contains a specific shortcode
- Display height and width properties with the_post_thumbnail() or related function
- Insert width & height attributes to all images displayed on each page
- Function to show only first instance of shortcode
- Display a text message if the shortcode is found?
- Custom image size in Media Dropdown
- Best way to programatically add “rel” attributes to page and post images
- Removing the first image in content
- Function to auto-set a featured image that is already in use
- Actions according to image type and size
- Woocommerce Storefront WordPress Ignore Media Gallery Images and use External 3rd Party Host
- creating shortcode to pull json array
- Overwrite Parent Theme add_image_size in Child Theme
- Images uploaded using media uploader are appearing upside down
- How to add css class to image attached in all the posts?
- Custom Shortcode, functions PHP WP_Query loop
- Add custom image size not working
- Pass Shortcode Attribute to footer Script
- Super simple shortcode not working
- Detect Safari desktop browser and include the detection in a shortcode
- Count total number of images in post and echo results as number
- My simple custom shortcode is not longer working (possibly due to upgrade to WordPress 4.4 ?)
- Display gallery on top before content
- How can you limit srcset on a single type of page?
- List child pages of specific page using shortcode
- how to add an image to the footer?
- How to extract the variables out from “add_shortcode” function?
- wp_get_attachment_image function size argument not working if I also add a custom class
- Display first name of logged in user?
- How to get specified parent page title in my function
- Possible to display shortcode based on the category?
- WordPress shortcode attributes for database SELECT?
- Automatically wrap multiple images in div
- Shortcode pagination not advancing
- create shortcode to list users with specific meta key value
- Variable if post is sticky in functions.php
- Having issues with a foreach inside of a shortcode with ACF gallery
- Understanding and altering the structure of posted images
- Overwriting Parent Theme’s Image Sizes
- Shortcode inserts paragraphs before and after executing shortcode
- Image rotation fails to regenerate custom sized thumbnail
- Publish/Update post is changing image links from file url to post url
- Featured Image Thumbnail Creation
- Display post shortcode content in the sidebar?
- Twentyten Child Theme: header images display messed up in admin panel
- Disable auto-resizing of uploaded images, but only for certain filename
- Display images that are not in the content
- How to get the index number of the posts?
- Can you put a condition on add_image_size() depending on the width of the uploaded image?
- Using shortcode content with nested shortcode
- show first 3 thumbnails of posts in different sizes [closed]