In your post you wrote : “which will show an image like below”, I assume that your shortcode return an img
tag and you have to find your URL here, tell me if I’m wrong.
Using DOMDocument
http://php.net/manual/fr/class.domdocument.php to parse your img
tag is a good idea.
$img = do_shortcode('[user_meta_avatar_pic]'); // Here your get your img tag
// Use DOMDocument to parse your img tag
$dom = new DOMDocument();
$dom->loadHTML($img);
$img_url = base64_encode($dom->getElementsByTagName('img')->item(0)->getAttribute('src')); // Encode the extracted src from your img tag
You can also use regex, I have no idea about performances comparison beetween a regex and DOMDocument
.
Related Posts:
- Remove images from get_the_excerpt
- Redirect to another page using contact form 7? [closed]
- Visual Composer creating own shortcodes with vc_map() to return simple Image
- how can I change all wordpress media file url to custom cdn url?
- Using Switch Statement to Change Image According to Last Digit of Topic ID
- Missing feature image link function
- What’s the difference between home_url() and site_url()
- 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
- Prevent “main” WPMU site_url() being returned in functions
- Custom page with variables in url. Nice url with add_rewrite_rule
- 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?
- Is it possible to use a forgot password url filter?
- Create Custom URL structure for specific Post category
- 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 can I rename the WordPress AJAX URL? [duplicate]
- 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
- How do i reference the theme path in pages for images?
- 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?
- Ninja form Redirect depending on text field content [closed]
- How to extract the variables out from “add_shortcode” function?
- Shortcode for a link and thumbnail
- 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