Passing JS var to PHP in media manager

For Joomla! 3.x Coding related discussions, you could also use: http://groups.google.com/group/joomla-dev-general

Moderators: ooffick, General Support Moderators

Forum rules
Locked
Gloop
Joomla! Apprentice
Joomla! Apprentice
Posts: 18
Joined: Thu May 22, 2014 11:14 am

Passing JS var to PHP in media manager

Post by Gloop » Thu Oct 01, 2015 10:28 am

I want to automatically make resized copies of images added to articles using the media manager. I've got a small PHP script that's meant to do this once the Insert button has been pressed.

I've added the script into the onclick function on line 39 of administrator/components/com_media/views/images/tmpl/default.php. I'm unable to post the relevant code, even in tags, so I've attached it as a text file.

I've set a JS variable toPass = document.id('f_url').value.

This is the URI of the file to be inserted into the artice given as "images/file.jpg". I want to to send this value to PHP variable $filename.

I've been trying for days now. I'm new to JS & PHP and was hoping this would be a fairly easy thing to do, but I hadn't realised how complicated it would be.

I've had no luck using JInput or anything else I can think of. I'm completely ignorant when it comes to forms and GET/POST etc, nothing I've tried there works either. I may well be barking up entirely the wrong tree. Any advice would be fantastic.
You do not have the required permissions to view the files attached to this post.

harperlala
Joomla! Guru
Joomla! Guru
Posts: 697
Joined: Mon Aug 24, 2015 5:55 pm

Re: Passing JS var to PHP in media manager

Post by harperlala » Thu Oct 01, 2015 3:12 pm

you can use jquery API to get the value of your varriable.

Gloop
Joomla! Apprentice
Joomla! Apprentice
Posts: 18
Joined: Thu May 22, 2014 11:14 am

Re: Passing JS var to PHP in media manager

Post by Gloop » Sat Oct 03, 2015 1:02 am

Thank you a million times over! I've got something working; not quite how I wanted it, it requires an external PHP file, but it's working.

If only I could buy you many beers!


Locked

Return to “Joomla! 3.x Coding”