Try using some API from WordPress itself – https://codex.wordpress.org/Function_Reference/wp_localize_script
Related Posts:
- Create Image Uploader for Widget
- How to resize image on client-side before upload?
- Echo URL of large version of Featured Image
- How to change redirection route to a php page for making it only accessible by logged-in members?
- Scrape external webpage for first image and add it to new post
- Redirect to another page using contact form 7? [closed]
- I’m unable to call img path using single quotes in an array?
- How do i add slugs to a URL, but still redirecting to the same page
- Some problems in custom widget
- Unable to display multiple parameters from url by javascript through shortcodes
- Prepend to all image URLs with PHP, only for mobile devices
- Show next image in array if page is revisited by same logged user
- I can’t load my images from a js file using wp_localize_script
- I want url from a file in media using title file
- Retrieve first image url from custom post with pagination
- How to insert a local image with custom size
- Change logo based on incoming domain
- How is WordPress manipulating the posts like there are folders?
- javaScript in section of WP API
- Styling images coming from another blog
- admin-ajax.php responding with 0
- Using wp_localize_script to store the template url into a variable to use in JS
- How to scale image with equal width and height without distortion?
- How can the plugin directory path be returned into ?
- Theme currently showing thumbnails, how to show full size?
- How can I add tinymce editor in WordPress with jQuery?
- How to speed up admin-ajax.php in wordpress
- JQuery not working on WordPress Admin page [closed]
- Customizer Show/Hide
- Page Reloads Before AJAX Request Finishes
- Validate Uploaded Image using WordPress’ Built-in Functions?
- Get most recent media upload
- Colorbox ajax loading of outside HTML content works perfect on localhost but not on server
- How to make custom total price reactive in navigation
- Adding tawk.to code just before body tag on functions.php file
- How do I fetch all comments per post via WP REST API?
- Deregistering a script in WordPress seems impossible
- Slide in Panel WordPress Post
- Sending jsPDF documents to the server
- IMG src weird behaviour inside a single post loop
- How to prevent those PHP variables from being cached on WordPress?
- Convert all images to PNG on file upload
- Escape post image attachments added to template
- Extract subdomain and relative address from a url
- Remove query string specific key value
- Ajax return code 400
- How can I add an alert (like the old javascript alerts) to my WP page?
- Auto crop images in WordPress
- Display post image with fancybox
- Pass PHP variable to JavaScript without inline JS
- Show post in slider
- How can I output a php value into a JS file within WordPress?
- Using shipped version of jquery
- How to get media objects
- PHP code to call image Caption, Alternative Text, and Decription?
- Putting PHP variables into javascript [duplicate]
- Bridging TinyMCE js and WordPress PHP?
- Why does WordPress remove my variables in the URL?
- How do I let users upload files to a chosen location?
- Trying to implement Ajax comments in WordPress, getting WP error
- How to test nonce with AJAX – Plugin development
- Change the URL of an image from wp_get_attachment_image_src except in the frontpage
- Get different images for mobile and desktop with php, advanced custom fields without using js and ajax
- How do I display a user’s previous orders as a select box option on a product?
- Simple Plugin with custom javascript wont work – no console error
- How does this WordPress Plugin (Thrive Comments) apply their custom comment sort? [closed]
- How can I use a modal window to display the current post in loops featured image?
- How to get specific image in media library with php
- js file in root loading without
- hover image appears below placeholder instead of overlayed
- class click counter save number
- Trigger popup in a php if/else statement
- Slider loading issue
- AJAX request status 200 but no actual “response”
- Button not refreshing page
- Ajax not working es expected (Returns 0)
- add_image_size for header_image
- Use menu link or onClick to set a variable
- Add custom url to featured image
- Get image’s size name from it’s dimension
- Cannot display or echo alt text on featured image
- Recent posts with featured image or fallback image with permalink
- How to select the contents in the text view textrea in wp_editor?
- Creating a Multi-Level Associative Object Using AJAX
- WP functions in .js
- Adding custom directory and PHP files in wordpress
- Best practice for migration friendly images in posts/pages?
- Set the background to a default image if there isn’t a specified “featured image”
- Ajax – Call to undefined function get_option()
- Mass update excerpt
- Populate dropdown with Child Pages based on Parent Page chosen
- remove wp floating submenu in wp dashboard
- How to control WordPress image metadata (using Imagick)?
- Displaying admin notices inside the block editor from rest_after_insert_{$this->post_type} hook
- search and replace preword from author
- How to prevent XSS alter custom global javascript object & methods in WordPress
- How to complete two other input fields, completed the first
- Status 400 for AJAX POST Request with admin-ajax.php
- How to inject variables into public-facing JS using wp_enqueue_script
- How to pass aa JS variable to PHP?