Part 7 - WordPress Theme Development - Use the WordPress Media Uploader

แชร์
ฝัง
  • เผยแพร่เมื่อ 24 ธ.ค. 2024

ความคิดเห็น •

  • @jeff-wo6mm
    @jeff-wo6mm 4 ปีที่แล้ว +2

    I'm convinced that any downvotes are from trolls who just go around downvoting videos for fun. This has been a great tutorial so far

    • @alecaddd
      @alecaddd  4 ปีที่แล้ว

      I suspect that too 😃

  • @xee_shan
    @xee_shan 2 ปีที่แล้ว +2

    this is the best tutorial that i could find on this topic in 2022, cheers.

  • @DraganGajic89
    @DraganGajic89 9 ปีที่แล้ว +7

    Awesome tutorial, thanks!
    Small hint for other viewers: If you struggle with 'mediaUploader' not opening there is a small sudden change on line 5 at 17:04 , keep your eye on that ;)

    • @alecaddd
      @alecaddd  9 ปีที่แล้ว

      +Dragan Gajić Thanks for the heads up. I explained that small change almost at the end of the video. I noticed while editing that the recording skipped that part. Thank you so much for your help!

    • @DraganGajic89
      @DraganGajic89 9 ปีที่แล้ว +2

      +Alessandro Castellani Yeah, I saw it later, but unfortunately I forgot to edit comment since I was working along the video and when I came on the problem then I kinda struggled to find a way to solve it and when I did i was playing that part over and over again and then I saw the change, but later I saw that you have explained it, but anyway I think comment maybe can be helpful to other viewers who work along the video. Best regards, and keep it going I am sure that you will get a lot of views and subscribers.

    • @alecaddd
      @alecaddd  9 ปีที่แล้ว

      Thank you so much, and I'm sorry for the trouble :D

  • @maxcanzonieri
    @maxcanzonieri 7 ปีที่แล้ว +2

    Hello Alex,
    you're really awesome to teach. Your videos are simple, easy and your english is perfect for everyone that not speak and talk it every day.
    Bye

    • @alecaddd
      @alecaddd  7 ปีที่แล้ว +1

      Hi, thank you so much, or I should say "grazie mille" :P

    • @maxcanzonieri
      @maxcanzonieri 7 ปีที่แล้ว +1

      ahahah in effetti è decisamente meglio.... sei uno dei pochissimi italiani a fare degli ottimi video tutorial :) direi che mi stai dando una bella mano ad accelerare le mie conoscenze:)

  • @robeeeeen
    @robeeeeen 4 ปีที่แล้ว +2

    Still now in this Pandemic Year (2020), Your code and solution for Wordpress Theme Option is the best. Thank you very much!!!

  • @BG-xu8be
    @BG-xu8be 7 ปีที่แล้ว +2

    14:32 I thought the "e" in $(‚#upload-button‘).click(function(e){}); refers to the event (in this case mouse click) and not direct to the button element itself...

    • @alecaddd
      @alecaddd  7 ปีที่แล้ว

      Yes, you're right, that was a brain fart >_>

  • @BoraDemircan
    @BoraDemircan 9 ปีที่แล้ว +4

    Great Tutorial! Thank you very much! How can we add multiple media upload fields?

    • @alecaddd
      @alecaddd  9 ปีที่แล้ว

      +Bora Demircan Thank you for following.
      You can use the same code to create more settings options and change the ID and Name of the html attribute.
      You have consequentially properly hook the javascript to the newly generated fields.

  • @jellycoding
    @jellycoding 9 ปีที่แล้ว +1

    I have a little question. When I see your code I can see that I have a lots of code that you don't have? I have som kind of wpemoji-code messing up my files? It even loads js-files? Do you know what that is? It must be some kind of Wordpress-thing?

    • @alecaddd
      @alecaddd  9 ปีที่แล้ว +1

      +jellycoding That is something WordPress implemented in version 4.2
      You can deactivate these extra with the wp-head function, the same way I will do in some of the next videos for the front-end, to remove unwanted tags.

  • @mathewi2761
    @mathewi2761 6 ปีที่แล้ว +1

    i understand that it is a lot to ask, but may be some day you will make a video about uploading files to wordpress, from user side(like a form with CV file or something like that) without plugins.

    • @alecaddd
      @alecaddd  6 ปีที่แล้ว

      I will, thanks for the request.

  • @raulterraferrao696
    @raulterraferrao696 8 ปีที่แล้ว +7

    I passed like 30 minutes to know what happened with my code because the button to upload the image did not work to me, i was clicking and nothing happened. That was not any typo, so to resolve the problem i cleaned the cache of my browser and re entered inside the admin painel and it worked.

    • @alecaddd
      @alecaddd  8 ปีที่แล้ว +1

      Thanks for sharing your experience, I'm glad it worked :D

    • @achristen07
      @achristen07 7 ปีที่แล้ว

      worked for me

    • @GualtioLT
      @GualtioLT 7 ปีที่แล้ว +1

      i spent 30 mins before reading your comment! now it's ok! thanx

    • @SoyLast
      @SoyLast 6 ปีที่แล้ว

      +1 for me, ctrl + f5 works also.

  • @deepak2499
    @deepak2499 8 ปีที่แล้ว +3

    Alessandro Castellani Thank you so much. tutorials helped me a lot to make custom theme options. you explain everything in details makes it easy to understand. thanks so much
    cheers :)

    • @alecaddd
      @alecaddd  8 ปีที่แล้ว

      Thank you so much

    • @phungduyphong3457
      @phungduyphong3457 8 ปีที่แล้ว

      gonna go through all of this and more, tks alot, you saved my life

  • @devchauhan21
    @devchauhan21 5 ปีที่แล้ว

    Thanks so much. I have been watching your tutorials and found them immensely useful. However, I searched the whole channel but couldn't find a video tutorial on "Implementing WP Media library For Front End User", like for the front end dashboard. Please upload it if possible.

  • @ArifBillahOnGoogle
    @ArifBillahOnGoogle 8 ปีที่แล้ว +1

    Good one! I also added some other functionalities for example : a reset button to the form a confirmation on reset. Thanks!

    • @alecaddd
      @alecaddd  8 ปีที่แล้ว +1

      +Arif Billah Good job! I'm glad you're able to expand the functionalities and customize the code for your needs.

    • @ArifBillahOnGoogle
      @ArifBillahOnGoogle 8 ปีที่แล้ว

      Can you please create a video on Settings API with ajax in a proper way? This will help us very much.

    • @alecaddd
      @alecaddd  8 ปีที่แล้ว +1

      +Arif Billah I will definitely do that in future tutorials.

    • @ArifBillahOnGoogle
      @ArifBillahOnGoogle 8 ปีที่แล้ว

      Thanks again.

  • @rekss9252
    @rekss9252 5 ปีที่แล้ว +1

    i need help my mediauploader dont open

  • @prashantkushwah9023
    @prashantkushwah9023 4 ปีที่แล้ว

    Hey Alex! Can i Change the Path of the upload of directory.

  • @daviddelvin8783
    @daviddelvin8783 5 ปีที่แล้ว

    Hi Alessandro! Awesome video I really appreciate your tutorials. I have a question concerning the profile-image. I understand how you are doing it, but I would like to create a dynamic input for multiple images. (preview of the images that i selected in the uploader). however it only shows me the first one. I tried using .each, but will not work. would you have an idea why it's not working? also, if ever you're in Calgary, let me know! thank you cheers!

  • @almasrafaqat2791
    @almasrafaqat2791 4 ปีที่แล้ว

    Dear Alessandro Castellani,
    Thanks for your helpful videos. i am following this playlist but on this video i have stuck. i can't open the media while click on the button. Please see below the code is there any fault?
    jQuery(document).ready(function($){
    var mediaUploader;
    $('#upload-button').on('click', function(e){
    e.preventDefault();
    if(mediaUploader){
    mediaUploader.open();
    return;
    }
    mediaUploader = wp.media.frames.file_frame = wp.media({
    title: 'Choose a Profile Picture',
    button: {
    text: 'Choose Picture'
    },
    multiple: false
    });
    });
    });

  • @MarkPitt
    @MarkPitt 8 ปีที่แล้ว +1

    The difference between
    "register_setting(' sunset-settings-group', 'profile_picture' );" and
    "register_setting( 'sunset-settings-group', 'profile_picture' );"
    Can break your coding....
    By the way - enjoying these tutorials, excellent work Alessandro Castellani!

    • @alecaddd
      @alecaddd  8 ปีที่แล้ว +1

      Oh yes, just an empty blank space can cause a looooooot of issues :D
      Thank you so much for watching.

  • @Kundusamir
    @Kundusamir 6 ปีที่แล้ว +1

    Best tutorial ... Thanks for explaining each topic, functions, etc... Thanks again

    • @alecaddd
      @alecaddd  6 ปีที่แล้ว

      You're very welcome :D

  • @helmutgobel4249
    @helmutgobel4249 8 ปีที่แล้ว +1

    Hi Alex, 3 more questions: On my admin-page I want the admin to select a favicon and a company-logo. 1. Can I duplicate the JS-Code (with the little changes) in the same JS-file or create a new one and duplicate the 'wp_register_script' and 'wp_enqueue_script' in the enqueue.php? 2. I can't display the favicon. Can I? 3. If it is not possible to display the favicon itself, how can I display the path and/or the filename?

    • @alecaddd
      @alecaddd  8 ปีที่แล้ว +1

      +Helmut Göbel Yes you can duplicate the JS code in the same JS file. Be careful with variables name and to not overwrite other settings.
      Favicon can be also GIF or PNG format, PNG it's actually the most recommended. With that you can easily display it, and give the users the ability to upload it in their own library.
      Happy Coding!

  • @luiscporem
    @luiscporem 7 ปีที่แล้ว +1

    Hi, Amazing video tutorials!!! One question: if I wanted instead to have the logo loaded as an image and not as a background, how would be the code to refresh the logo?
    in the admin.php:

    • @alecaddd
      @alecaddd  7 ปีที่แล้ว

      This should do the trick:
      $('#logo-header-preview').attr("src",attachment.url);
      Update the SRC attribute of your IMG tag with jQuery.

  • @fengshuienthusiast7635
    @fengshuienthusiast7635 6 ปีที่แล้ว +1

    I could not figure out what I did wrong that would cause the button to not work. I did a few things, replaced the code with your code, and nothing. I was about to give up and then put back the hash tags in the jQuery file and click on it and it works.....I do not know what was wrong but now it works.....argh. jQuery always gives me fits but it is so much fun when it works for me.

    • @alecaddd
      @alecaddd  6 ปีที่แล้ว

      hashtags? Can you share a small code snippet of when the button wasn't working? At least we can identify what was the problem :D

    • @andibeben6430
      @andibeben6430 6 ปีที่แล้ว

      Actually the button is working. I added a dummy text, that is hidden when the button is clicked. And it's work - the text is hidden. But the mediaUploader is not opened. Only after the 2nd click the mediaUploader is opened. I don't know why??

    • @fengshuienthusiast7635
      @fengshuienthusiast7635 6 ปีที่แล้ว

      Oh, I meant apostrophe's. I always miss putting the leading or following apostrophe or forget to close out a comment or command with a semicolon. No worries I am sure it was just a simple oversight. I understand your explanation in the tutorial. Thank you Alessandro! Your tutorials are always clear and understandable.

  • @ankitsharma1943
    @ankitsharma1943 6 ปีที่แล้ว

    i am not getting the image in the sidebar .when i insepecting the element the value is showing the url of the image

    • @alecaddd
      @alecaddd  6 ปีที่แล้ว

      Check my source code on GitHub to see if you have any typos.
      Cheers

  • @sudhakarsudha9655
    @sudhakarsudha9655 7 ปีที่แล้ว

    hai can you suggest how in admin options i need to have a icons upload droplist where i can leran any idea or any tutorials blog can you refer me

  • @azen2187
    @azen2187 6 ปีที่แล้ว

    Hi, sorry im new to this thing. but could you explain why we need the preventDefault()? If we don't use it what will happen?

    • @alecaddd
      @alecaddd  6 ปีที่แล้ว

      preventDefault() is necessary to stop the normal behaviour during a trigger. In our case, we're clicking on a FORM submit with a button, and in order to allow us to do all the JS things we have to do, we need to prevent the form to be submitted, otherwise we'd have a page reload and we wouldn't be able to trigger our JS code.

  • @dayinlife5
    @dayinlife5 6 ปีที่แล้ว

    Hi Alex , thank you for the AWESOME tutorials i have ever seen in youtube, your teaching style is SUPER cool dude. just silly question why you put value="'.$picture.'" in 27:00 if you gonna update the value in sunset.admin.js ??
    buona fortuna
    ;)

    • @alecaddd
      @alecaddd  6 ปีที่แล้ว

      Thanks for watching.
      Because when you load the page, you need that value in the HTML echoed with PHP as JS won't trigger automatically unless you use the media uploader.
      Try to not echo the picture variable and save the form without doing anything right after you access the page. See what happens :D

    • @dayinlife5
      @dayinlife5 6 ปีที่แล้ว

      you're right thank you Alex for the quick replay :)

  • @liammerlyn5280
    @liammerlyn5280 8 ปีที่แล้ว +1

    This is a fantastic series, Alec!
    I have one problem though, after creating a few fields: name, email etc. I tried to add an "Intro" textarea. but after trying to prefill the textarea with the saved Intro as with the other fields, it's simply displaying the PHP code inside the textarea.
    function theme_sidebar_intro() {
    $intro = esc_attr( get_option( 'intro' ) );
    echo '';
    }
    Is there something I've missed? The same code worked perfectly when using input fields.
    Thanks again.

    • @alecaddd
      @alecaddd  8 ปีที่แล้ว

      +Liam Merlyn You wrote a wrong echo function.
      You can't use the php tags inside and echo, and another echo.
      To print a variable inside an echo, you have to use the dots. In this way:
      echo '' . $intro . '';

    • @liammerlyn5280
      @liammerlyn5280 8 ปีที่แล้ว

      Hi Alessandro, thanks so much for that. I could have sworn I'd already tried to do that ha!
      Anyway, thanks again. Funnily enough, I only came to Part 4 looking for an answer to something and ended up watching the entire series! It's helped me immensely! I'm shocked you're not selling this course on Udemy or similar. Thanks again!

  • @nickfonseca8488
    @nickfonseca8488 9 ปีที่แล้ว +1

    Problem: So when i try to upload the image file I got no image. I get a broken file like icon. I was getting a few errors previously but fixed them since. the other issue I'm seeing is when I change the facebook text it never updates. I get what ever was originally set. Is this the right place to submit my code?

    • @alecaddd
      @alecaddd  9 ปีที่แล้ว

      +nick fonseca Before doing anything, try to check my source code on GitHub and see the differences. If you have some typo or unique names not matching, it could create a lot of issues.
      Cheers

  • @algryshko
    @algryshko 6 ปีที่แล้ว

    Maybe you know whether you can limit the download of a file by the mime type?

    • @alecaddd
      @alecaddd  6 ปีที่แล้ว

      I know how you can restrict the upload by mime/type, but I'm not sure about the download.
      Sorry

    • @algryshko
      @algryshko 6 ปีที่แล้ว

      Alessandro Castellani oh sorry, this is my mistake, I need to limit the mime type for uploading files

    • @algryshko
      @algryshko 6 ปีที่แล้ว

      Alessandro Castellani can you tell me how to do it?

  • @ggkr8213
    @ggkr8213 7 ปีที่แล้ว +1

    Great work! you became my go to source of information when it comes to wordpress development. Thank you!!
    also, Is it possible you can make an episode dedicated for the media uploader? It took me like two hours only to manage to use multiple selections, and I feel like I just scratched the surface. I am still looking to limit the file types that can be used and modifying a multiple selection (reopening the selection box will have the images previously saved already selected)

    • @alecaddd
      @alecaddd  7 ปีที่แล้ว

      Hi, thank you so much for watching.
      Sure, I will do a mini series about the uploader, probably I will wait a bit because it's currently under redevelopment with React, if I'm not wrong.
      Happy Coding!

  • @DirectwebCoUk
    @DirectwebCoUk 7 ปีที่แล้ว +1

    Hi great tutoring first of all been a massive help for a beginner, i placed the upload code and the button shows and the url of the image i want to use shows up in value but when i hit save the url does not save and vanishes for the value section. I have checked the code with the code on video and also with the code on github and still not working.
    Please help. Thank you

    • @alecaddd
      @alecaddd  7 ปีที่แล้ว

      Did you also copy my code from Github? Everything still works for me, so I'm not sure what could be the problem.

    • @DirectwebCoUk
      @DirectwebCoUk 7 ปีที่แล้ว

      i copied it over rewatched the video at least 10 times, i put the text box into the area what showed the url but when saved it vanished, really puzzled me

    • @DirectwebCoUk
      @DirectwebCoUk 7 ปีที่แล้ว

      All ok know not sure what it was but I must have missed it as replaced everything with GitHub for season 7 and edited everything again so it fits my front end. On to part 8 fantastic tutorial, have you done a video on when install theme it provides you with options to install recommended plugins

  • @divikingdom6937
    @divikingdom6937 8 ปีที่แล้ว +1

    Before everything thanks very much for this awesome tutorial.
    I've a question: is it the enough to use
    wp_enqueue_style( 'admin-style', get_template_directory_uri() . '/css/admin.css' );
    Or we have to use wp_register_style() and then wp_enqueue_style() ??
    the same for wp_enqueue_script ?

    • @alecaddd
      @alecaddd  8 ปีที่แล้ว

      +Sailor Abood Thank you for following.
      Yes, you can totally use directly the enqueue without register.
      The register is useful if you need to enqueue a file in different pages with exceptions and conditions, so you register the file before, and then you enqueue it wherever you want without re-registering the same file again.
      Happy Coding!

    • @divikingdom6937
      @divikingdom6937 8 ปีที่แล้ว +1

      +Alessandro Castellani Thanks man, you r the best :)

  • @fixitnow9612
    @fixitnow9612 6 ปีที่แล้ว

    Very good tutorial series! Well, i have problem with automatically replace image don't change why? Code it's correct but why? Any ideas please...

    • @alecaddd
      @alecaddd  6 ปีที่แล้ว

      Did you check my source code on GitHub?

  • @certificadosantonio7551
    @certificadosantonio7551 6 ปีที่แล้ว +1

    I know it's going to sound like a stupid question but, do I just repeat the JS code with different ID's and variable names for multiple image uploads or is there a cleaner way to do it?

    • @alecaddd
      @alecaddd  6 ปีที่แล้ว

      Not a stupid question at all, and thanks for asking :D
      You could do what you suggested, or you could refactor the code to be attached to a class instead of an ID, but then you need to rewrite a bit the javascript in order to handle the returned value from the upload properly for each field.
      Happy Coding :D

    • @certificadosantonio7551
      @certificadosantonio7551 6 ปีที่แล้ว +1

      Thanks Alessandro, I thought it was going to be messy to repeat pieces of code but the code looks clean and it's working perfectly with the first solution (I used the repeat solution because I'm not very good at JS).
      Haven't finish all of it (the full tutorial) but I've learned so much about custom theme options... Great tutorial!
      Thanks for the answer and for the tutorials.

  • @KirschblutenTsunami
    @KirschblutenTsunami 7 ปีที่แล้ว

    Thank you so much for this tutorial! I've searched for one of these for ages!!!
    I have a little question though.
    If I want to implement more than one select option, e.g. "Upload Profile Picture" and "Upload PDF of CV" how do I have to change the .js file? I tried out a view things but it never worked.
    Help would be awesome :)
    Thank you again for all of your tutorials! It's so easy to understand and I have so much fun following along!

    • @alecaddd
      @alecaddd  7 ปีที่แล้ว

      Hi, thank you for watching my videos, I'm glad they're helpful for you.
      To use the media uploader multiple times, you need to create different inputs with different IDs and update the JS file to use the proper input fields.
      If you need some code examples and better instructions, please come to the forum and paste your code there, it'll be easier.
      forum.alecaddd.com/

    • @KirschblutenTsunami
      @KirschblutenTsunami 7 ปีที่แล้ว +1

      Thank you so much for the fast answer!!! I'm amazed :)
      Great, I'll try again and then join the forum! Thank you so much!

    • @alecaddd
      @alecaddd  7 ปีที่แล้ว

      You're very welcome :D

  • @rtraees
    @rtraees 4 ปีที่แล้ว

    Great Tutorial Solve my issue after watching this tutorial.
    Thanks

  • @nassimREHALI
    @nassimREHALI 4 ปีที่แล้ว

    Great tutorial ! Thank you alessandro

  • @alexk9024
    @alexk9024 8 ปีที่แล้ว

    How would you go about it to add a remove picture button? ( I use Advanced Custom Fields at work most of the time and it has that ability, this time I am trying to create a theme with the fields built into it though )

    • @alexk9024
      @alexk9024 8 ปีที่แล้ว +1

      Nvm! Just noticed you already have a video for that! Awesome

    • @alecaddd
      @alecaddd  8 ปีที่แล้ว

      Awesome, I'm glad I was able to predict your question from the past :P

    • @alexk9024
      @alexk9024 8 ปีที่แล้ว

      One more question though! I managed to create myself a color select field, but the regular HTML input field is pretty ugly and doesn't have the ability to add a hex code :s How would you go about this? ( This time I searched through your videos first haha )

  • @BucurIonNiculae
    @BucurIonNiculae 9 ปีที่แล้ว +1

    Another very good episode. Excellent work.

    • @alecaddd
      @alecaddd  9 ปีที่แล้ว

      +Bucur Ion Niculae Thank you so much

  • @luisramirez7361
    @luisramirez7361 3 ปีที่แล้ว

    Hola! Muchas gracias por los tutoriales, eh aprendido muchísimo, sin embargo eh intentado seguir el paso de JS y me da un error el cual dice "Uncaught TypeError: Cannot read property 'frames' of undefined" eh intentado ver si la eh regado en algo pero no, aparentemente el código es el mismo, alguna sugerencia?

    • @luisramirez7361
      @luisramirez7361 3 ปีที่แล้ว

      Corrección, ya ví dónde la regué me hizo falta el wp_enqueue_media();
      Gracias realmente

  • @ZaheerAbbasAghani
    @ZaheerAbbasAghani 9 ปีที่แล้ว +1

    very nice and Easy to understand.

  • @azizulhaque3194
    @azizulhaque3194 8 ปีที่แล้ว

    Thank you very much already i have follow all of your tutorial but one problem here, See this jQuery colde $('#profile-picture-preview').css('background-image','url(' + attachment.url + ')'); by the code you called background image from here but i want to include image in here, for not background

  • @ammarbakra8639
    @ammarbakra8639 6 ปีที่แล้ว

    when i click the button nothing happens and i find this error in console 'Cannot read property 'frames' of undefined'?

    • @alecaddd
      @alecaddd  6 ปีที่แล้ว

      Check my source code on GitHub if something doesn't work

    • @12noooooon
      @12noooooon 5 ปีที่แล้ว

      @@alecaddd i am coped the source code and the problem still there connot open ant thing with this button !!!

  • @taniyasilhi9783
    @taniyasilhi9783 7 ปีที่แล้ว

    Hi Allecaddd. I tried to add favicon to the admin panel When i upload favicon, the logo image also changes with the favicon image. What changes i need to make in the js code? So that it cannot replace each other.

    • @alecaddd
      @alecaddd  7 ปีที่แล้ว

      Did you check my source code on Github? Just to see if you have any typo

  • @bahaaalmahamid
    @bahaaalmahamid 6 ปีที่แล้ว

    Why do I need to click the button twice to open ?

  • @birdbrainsolutions6112
    @birdbrainsolutions6112 5 ปีที่แล้ว

    This tutorial is so amazing! You really are the best Alex!

  • @MireyElmofti
    @MireyElmofti 6 ปีที่แล้ว

    Hi Alex :)
    Thank you so much for your reply..
    This is the part i am having the problem, i have checked your lesson files and used them but i had the same error witch says
    wp is not defined in the bellow line , from the sunset.admin.js file :(

    mediaUploader = wp.media.frames.file_frame = wp.media({

  • @anasshamia7169
    @anasshamia7169 7 ปีที่แล้ว

    great job ♥
    ?? where i can found the media uploader code in Codex

  • @dillonoreilly5867
    @dillonoreilly5867 8 ปีที่แล้ว

    Hi Alex, Firstly thank you very much for the amazing video's I have never really programmed before and I feel that i have found another passion in life. Secondly, I have checked through my code and i cant find any syntax errors, although i will continue to check, just in case. but i was wondering if you know anything about the in wordpress version 4.5.3. i have included the $picture and the correct references to the functions file and js file. the media uploader is working, the value is correct, but the img src is'nt. there is no link in the qoutotations when i use the inspector but i have included the php print $picture code, (correctly syntaxed btw). Do you know if there might be problem due to the version of wordpress i am using??? thank you very much

    • @dillonoreilly5867
      @dillonoreilly5867 8 ปีที่แล้ว

      I figured it out, took me a day. I forgot one of the id's (embarassing) . Although, ive learned a lot more just from that one mistake.

    • @raulterraferrao696
      @raulterraferrao696 8 ปีที่แล้ว +1

      I got stuck about 1 hour with the same problem as you and guess what? After freaking out i realized that i was not saving the page clicking on the blue button, shame on me hahaha

    • @heshmania
      @heshmania 3 ปีที่แล้ว +1

      @@raulterraferrao696 I got the same problem -_-. HAHAHA

  • @georgecaplan11
    @georgecaplan11 3 ปีที่แล้ว

    As at April 2021 this jQuery code does not work for me. Is it possible to provide the pure javascript as I think this is no longer compatible with the most recent wordpress release. And i have definitely used the last code you provided in your github and it doesnt appear to work. Please clarify?

    • @chiroto
      @chiroto 3 ปีที่แล้ว

      Inside the enqueue file you need to add "wp_enqueue_media();" if there is an error with the "frames". It is included in the GitHub source files.

  • @garrafinhatati
    @garrafinhatati 7 ปีที่แล้ว +1

    I have a problem and I don't understand why... My jQuery is not defined so I can't load my picture. I can upload my image, but the img src is unkown. I already looked the code (source in your GitHub), re-wrote the code and nothing... I already cleaned the cache too.
    Could you help me?
    And by the way, thank you so much for these tutorials

    • @alecaddd
      @alecaddd  7 ปีที่แล้ว

      Thank you so much for watching.
      So, jQuery is not defined in your WordPress administration panel?
      That's really odd. What version of WP are you using?
      Did you try using the $ sign instead of jQuery?

    • @garrafinhatati
      @garrafinhatati 7 ปีที่แล้ว

      Exactly! jQuery doesn't work... and yes, I tried using $ :(
      I'm using WordPress 4.8.2
      I tried to disable the plugins too... nothing change! jquery is not defined

    • @fixitnow9612
      @fixitnow9612 6 ปีที่แล้ว

      Thanks dude i have same problem but why don't get the url with 1.0.0 and now all work perfect?

    • @theguire
      @theguire 6 ปีที่แล้ว

      So, what worked for me was closing out wordpress admin and restarting. I had to do it twice. First, when importing the profile pic and again after the changes to the css to stylize the profile component (and picture). Don't know why. But if you are having trouble with the jquery it might not be jquery. try restarting your wordpress site first. It's simple and takes almost no time... Worth a try.

    • @bahaaalmahamid
      @bahaaalmahamid 6 ปีที่แล้ว

      and don't forget to save changes after uploading as I did :D

  • @sudhakarsudha9655
    @sudhakarsudha9655 7 ปีที่แล้ว

    hey i have downloaded your theme from git hub and installed it but the media uploader is not working i think jquery is not working to memory cache in wordpress or browser i can not find it clearly can you help me

    • @alecaddd
      @alecaddd  7 ปีที่แล้ว

      It works perfectly for me, tested with the latest version of WP

    • @georgecaplan11
      @georgecaplan11 3 ปีที่แล้ว

      @@alecaddd I dont think this works as at April 2021.

  • @1717truth
    @1717truth 7 ปีที่แล้ว

    I get the following when trying to upload photo: Uncaught TypeError: Cannot read property 'frames' of undefined.... Any clue?

    • @alecaddd
      @alecaddd  7 ปีที่แล้ว

      Did you check my source code on Github?
      Do you have any Console error when clicking on the Media Uploader button?
      Give me more info and I'll try to figure out your issue

    • @1717truth
      @1717truth 7 ปีที่แล้ว

      Yes, I verified code from source, only difference is name of my theme. Here is the error i'm getting in console when clicking button
      prim.admin.js?ver=1.0.0:12 Uncaught TypeError: Cannot read property 'frames' of undefined
      at HTMLInputElement. (prim.admin.js?ver=1.0.0:12)
      at HTMLInputElement.dispatch (load-scripts.php?c=1&load[]=jquery-core,jquery-migrate,utils&ver=4.8:3)
      at HTMLInputElement.r.handle (load-scripts.php?c=1&load[]=jquery-core,jquery-migrate,utils&ver=4.8:3)

    • @1717truth
      @1717truth 7 ปีที่แล้ว

      No clue what the issue is, the button still throws the error in the JS console. See above comment for error

    • @1717truth
      @1717truth 7 ปีที่แล้ว

      Alessandro, I fixed it, was missing the wp_enqueue_media. Thanks for awesome tutorial!

  • @Lobotommy110
    @Lobotommy110 6 ปีที่แล้ว

    Can't connect or media library sb else the same issue?

    • @alecaddd
      @alecaddd  6 ปีที่แล้ว

      Check my source code on GitHub if something doesn't work. And be sure your WordPress setup is fully working.

  • @markwaters5964
    @markwaters5964 9 ปีที่แล้ว +1

    Another Great tutorial! Thanks Alessandro.

    • @alecaddd
      @alecaddd  9 ปีที่แล้ว

      +Mark Waters Thank you again for following

  • @poorvijain7281
    @poorvijain7281 6 ปีที่แล้ว

    Hello Dear,
    My "Upload profile picture button not working, Please resolve this query.
    Thanks"

    • @alecaddd
      @alecaddd  6 ปีที่แล้ว

      Check my source code on GitHub to see if you have any typos

    • @poorvijain7281
      @poorvijain7281 6 ปีที่แล้ว

      I checked ,,but its not working

    • @HTSHSHOW
      @HTSHSHOW 5 ปีที่แล้ว

      @@poorvijain7281 mee too

  • @mateenkiani6858
    @mateenkiani6858 6 ปีที่แล้ว

    Hey Alex! You are doing great. I am having a problem with media button. It's not working I have cleared cache and used another browser as well but the problem is still there.
    I think JavaScript file is not triggered properly. Even when I put some random words in the sunset.admin.js file I didn't get any error message. I am struck at this point .
    Anxiously waiting for your reply!
    Kind regards,

    • @alecaddd
      @alecaddd  6 ปีที่แล้ว

      Check my source code on GitHub and see if you have any typos or differences with yours.
      Cheers

    • @mateenkiani6858
      @mateenkiani6858 6 ปีที่แล้ว

      Lol 1 alphabet was written in caps which caused the whole mess

  • @yousram8890
    @yousram8890 8 ปีที่แล้ว

    Hello!
    Thank you for the tutorial series!
    The explanation and the code is all clear and thank you for providing the source files!
    I have a problem with the button tho, it's not working.
    I tried it by myself twice following your video, didnt work.
    So i copy pasted your code that you provided like three times exact the same copy paste but still the button is not working. It's not opening anything.
    Is it something to do with the WordPress version?! Mine is 4.5.3

  • @akashsahu4139
    @akashsahu4139 7 ปีที่แล้ว

    The upload button is not working at all. I have tried everything but nothing is happening.
    please help me with this.
    please help me with this! I have done the code identical to what in the video but it is still not working.

    • @alecaddd
      @alecaddd  7 ปีที่แล้ว

      Take a look at my source code on GitHub to see if you have any typos.

  • @darkprince1250
    @darkprince1250 8 ปีที่แล้ว

    I have a question here. why $picture=esc_attr(get_option('profile-picture')); doesn't work at first place and make us have to use jquery to edit the value attribute by ourselves. isn't it supposed to work as in the previous examples like first name, last name and all the rest of form fields ??!

    • @alecaddd
      @alecaddd  8 ปีที่แล้ว

      The fields "first name", "last name", etc. are visible fields that you update by typing the content.
      The field that controls the picture and allows the form to be submitted with the new picture information, is an hidden field, so as a user you can't directly update the value of that field.
      That's why we need jquery to capture the value of your uploaded picture and put it into the hidden field.

    • @darkprince1250
      @darkprince1250 8 ปีที่แล้ว

      really thankful for your quick response.
      i don't want to be rude but i am not convinced as if i create a file with the following content

    • @alecaddd
      @alecaddd  8 ปีที่แล้ว

      Dark Prince You're not rude at all, I just think you have a bit of confusion in understanding what "hidden" means in HTML.
      What's your knowledge of HTML markup?

    • @darkprince1250
      @darkprince1250 8 ปีที่แล้ว

      okay I think I know HTML markup well. hidden will make the hidden and not appear on the web page and as you said the user can't assign values to it directly. anyway it's not shown to the user. the developer should assign the value but what i mean why jQuery. i think assigning the $picture variable to the value attribute is enough to make it works. according to my understanding, the $picture variable isn't inserted by the user directly, it uses get_option() which captures the data from the WP database after inserted by user of course. so now we have value=$picture. i think it's really straightforward and must work. where am i wrong?

    • @darkprince1250
      @darkprince1250 8 ปีที่แล้ว +1

      oh i think i got it now. i thought the image url is inserted automatically to wp database when we upload the image. i didn't realize we are the one who should do it manually.
      thanks man ;)

  • @johnglennlambayon2412
    @johnglennlambayon2412 8 ปีที่แล้ว

    hello, i'm stuck i cant see my admin.js file in the page source or the inspect window of my browser. please help :)

    • @alecaddd
      @alecaddd  8 ปีที่แล้ว

      When issues like this happen, I suggest always to check my source code on GitHub and see if you have any typos or mistakes.
      Cheers

    • @hainguyenhuynh7342
      @hainguyenhuynh7342 8 ปีที่แล้ว

      I got same issue. I found that the button id was different. After fixing the issue, admin.js appears in the inspect. Hope this help.
      Thank Alessandro Castellani for the tutorial :)

  • @mdahmedmaruf
    @mdahmedmaruf 9 ปีที่แล้ว +1

    Great series keep going, this one helps me a lot.
    Thanks.

    • @alecaddd
      @alecaddd  9 ปีที่แล้ว +1

      Thanks for following, I will publish the next video tomorrow.
      Happy Coding!

  • @redrambles
    @redrambles 9 ปีที่แล้ว +1

    Very good tutorial series!

    • @alecaddd
      @alecaddd  9 ปีที่แล้ว

      +Ann Cascarano Thank you so much

  • @wanderdev
    @wanderdev ปีที่แล้ว

    For any of those that got some problems, here some of the details I missed
    - careful with the casing when writing jQuery
    - if it does not recognize jQuery, remember to add it to array list array('jquery');
    - add wp_enqueue_media(); to the enqueue functions
    - if the scripts and css are not loading, check if you have added action called 'admin_enqueue_scripts'
    These are all in the video however, maybe if you are coding along like me, you might get some of those wrong, hope it helped someone.

  • @valudconsultingllc8694
    @valudconsultingllc8694 6 ปีที่แล้ว

    Hello Alessandro,
    This is an excellent tutorial on how to wp media uploader works. I have small suggestion and request for extended part of this video.
    In this lesson, you have shown how to use multiple=true and select multiple images. But you have only printed it on console.log.
    It should be great if you show how to store multiple images on database and show it to front end.
    Another video topic suggestion is on upload media button in meta box, how to we can add repeatable upload button fields and upload, store and show multiple images on the front end.
    Currently no any such kind video available on youtube. You may really have a golden chance make video on repeatable image upload field in meta box.
    Thanks

    • @alecaddd
      @alecaddd  6 ปีที่แล้ว

      Thanks for the suggestion.
      Cheers

  • @carloseduardoparracarrizo466
    @carloseduardoparracarrizo466 7 ปีที่แล้ว

    I have a problem, the button not work for me! I cleaned the cache of my browser and nothing happened! help please!

  • @НиколайПридачин-в6т
    @НиколайПридачин-в6т 7 ปีที่แล้ว

    How to make multiple upload fields? i'm trying to copy the code and change id's but its not working
    Thanks

  • @ckgringoblogger9170
    @ckgringoblogger9170 6 ปีที่แล้ว

    Hey Ale, how are you?
    thanks for the amazing class, im newby to wordress theme development, finished your 1st course, very happy, and now im learning this one and somehow im stuck in this class cause somehow my code to print the preview photo its not working, i did exactly as u did and also i copy your code from github and didnt work either, maybe php version or something related? Thanks Brother

    • @alecaddd
      @alecaddd  6 ปีที่แล้ว

      Do you have any PHP or JS errors when encountering that issue?
      My code works with PHP from 5.6 to 7.2, tested all the way.
      Cheers

    • @ckgringoblogger9170
      @ckgringoblogger9170 6 ปีที่แล้ว

      It doenst show any error, just dont show the photo but when i click to upload its working but even like that i cant see the path in the inspector. :(

  • @verenapues3106
    @verenapues3106 7 ปีที่แล้ว +1

    First of all thank you so much for your super awesome tutorials!
    Can somebody help me with this issue?:
    Everything is working fine in Firefox, but for some reason the profile pic won't be displayed in Chrome :-/

    • @alecaddd
      @alecaddd  7 ปีที่แล้ว +1

      Thanks for watching. Did you open the chrome inspector to see if you have any issue or your image is there but not showing?

    • @verenapues3106
      @verenapues3106 7 ปีที่แล้ว

      Thank you for your super quick response! I still don't know what happened, cleared the cache a thousand times. But now after restarting my computer everything looks fine :P wohooo

  • @KhairulRodrokhairulsilencer
    @KhairulRodrokhairulsilencer 5 ปีที่แล้ว

    $('#profile-picture-preview').css('background-image', 'url(' + attachment.url + ')');
    this is not working for me. Why we can't use $('#profile-picture-preview').attr("src", `${attachment.url}`); this easy solution?

  • @sudhakarsudha9655
    @sudhakarsudha9655 7 ปีที่แล้ว

    hi for me all working but when when i upload image it not showing

    • @alecaddd
      @alecaddd  7 ปีที่แล้ว

      Are you getting an error when you try to upload an image? Does it work if you use the default media uploader of WordPress?

  • @jlambert12013
    @jlambert12013 3 ปีที่แล้ว +1

    I can’t believe this is free material

  • @bosbame8688
    @bosbame8688 7 ปีที่แล้ว

    help me sir i found error attachment = mediaUploader.state().get('selection').firts().toJSON();
    (Uncaught TypeError: mediaUploader.state(...).get(...).firts is not a function)

    • @alecaddd
      @alecaddd  7 ปีที่แล้ว

      Check my source code on Github and see if you have a typo.

  • @hasanmobarak7644
    @hasanmobarak7644 8 ปีที่แล้ว

    Hi, I'm try hard to do this but i can't . I didn't understand what is the problem. Can you/anyone share the source code of this video, plesae?

    • @alecaddd
      @alecaddd  8 ปีที่แล้ว

      You can find the source code, divided by lesson, in my official GitHub repository. The link is in the description of the video.

    • @hasanmobarak7644
      @hasanmobarak7644 8 ปีที่แล้ว

      thanks

  • @CyberIllusions
    @CyberIllusions 9 ปีที่แล้ว +1

    I was just checking your channel for updates, and yes, I got lucky again! THX, Alessandro! ;-)

    • @alecaddd
      @alecaddd  9 ปีที่แล้ว +1

      +CyberIllusions Or you're actually hiding underneath my chair, that's why you always know when a new video is up!

    • @CyberIllusions
      @CyberIllusions 9 ปีที่แล้ว +1

      +Alessandro Castellani: Yes, just like your dog does... ;-)

  • @FaisalAhmaditsfaysy
    @FaisalAhmaditsfaysy 8 ปีที่แล้ว +2

    Virtual high five for this great tutorial :D

    • @alecaddd
      @alecaddd  8 ปีที่แล้ว

      Many many high fives to you as well :D
      Happy Coding!

  • @12noooooon
    @12noooooon 5 ปีที่แล้ว

    the solved of button issue : try to do this :
    first : make sure about any wrong letter on enqueue.php and function-admin.php and sunset.admin.js files because i have a lot!! and that's why of not working ;) **** just copy the code from source files which Alex put it at lesson 1*** on descriptions and
    second : disable and enable the catch on inspector on network section
    third : clean you catch on you'r browser data ..
    then click twice on the button
    hope that's help :)

  • @sdfafojfaojfadojf
    @sdfafojfaojfadojf 7 ปีที่แล้ว +1

    This video just saved my day

    • @alecaddd
      @alecaddd  7 ปีที่แล้ว

      Glad I was helpful

  • @isabelphillips451
    @isabelphillips451 5 ปีที่แล้ว +2

    i have been wanting to know how to do this for a long time... OMG!! Alex, you're the best... everything you need to know about wordpress programming is here on this channel.

  • @valijonrahimov6765
    @valijonrahimov6765 8 ปีที่แล้ว +6

    Thumb up before watching:)

    • @alecaddd
      @alecaddd  8 ปีที่แล้ว

      That's a huge leap of faith :D

    • @grati24
      @grati24 8 ปีที่แล้ว

      Me too. Love this series.

    • @yassinyoussoufali6324
      @yassinyoussoufali6324 8 ปีที่แล้ว

      haha exactly the same here :DD

  • @Filipinjo
    @Filipinjo 8 ปีที่แล้ว +1

    Love your tutorials :)

  • @waqarulhassan4731
    @waqarulhassan4731 8 ปีที่แล้ว +1

    Great Work..Thumb UP

    • @alecaddd
      @alecaddd  8 ปีที่แล้ว +1

      Thank you so much!

  • @helmutgobel4249
    @helmutgobel4249 8 ปีที่แล้ว +1

    Hi Alex, you're doin' a great job with this awesome tutorials. Better than big books and videos from large publishhouses.
    I have a problem with this video, the mediaUploader doesen't work, like Dragan Gajić and Americo Perez already encountered. I used the latestest version code in this video, nothing happens, when clicking on the button. My code looks like this:
    jQuery(document).ready( function($) {
    var mediaUploader;
    $( '#upload-button' ).on('click' , function(e) {
    e.preventDefault();
    if( mediaUploader ) {
    mediaUploader.open();
    return;
    }
    mediaUploader = wp.media.frames.file_frame = wp.media({
    title: 'Choose a Favicon File',
    button: {
    text: 'Choose a File'
    },
    multiple: false
    });
    });
    });
    Ok, I want to upload a favicon, not a picture, and the Name of the Theme is "MTM-Bootstrap". But that shouldn't make a difference.
    The enqueue.php looks like this:
    Kann you see any mistake? Unfortunatly, I don't know any JavaScript (yet).

    • @alecaddd
      @alecaddd  8 ปีที่แล้ว

      +Helmut Göpel Did you try to copy my source code from GitHub? Probably something is missing in your code.
      Also, if you open the inspector in your browser, and check the console, did you get any error when you click on the upload button?

    • @helmutgobel4249
      @helmutgobel4249 8 ปีที่แล้ว

      +Alessandro Castellani Hi Alex, thank you for replying. The code in "enqueue.php" and in the js-file is the same, as in your files. The only difference is the name of the theme "mtm-bootstrap" (or mtm_bootstrap) instead of "sunset". When pushing the button the console remains empty. When I use your code from GitHub (chapter 7) in an other theme-installation, it works fine. Is any code in functions-admin.php involved?
      I don't have any clou where to check further.

    • @helmutgobel4249
      @helmutgobel4249 8 ปีที่แล้ว

      +Alessandro Castellani I made the mistake in the theme-functions.php. I forgot the 'class="button button-secondary"' and the 'id="upload-button"' in the input-tag. Your code works. Thank you again for your great tutorials.

  • @jrrb18
    @jrrb18 9 ปีที่แล้ว +1

    Waooo !!!!, just perfect !!, As usually By Master Alessandro Castellani

    • @alecaddd
      @alecaddd  9 ปีที่แล้ว

      +Jose Rafael Rojas B. *blushing*

  • @harounbouhdid9046
    @harounbouhdid9046 ปีที่แล้ว

    Nice job!

  • @ahmedsahir3988
    @ahmedsahir3988 5 ปีที่แล้ว +2

    20:57 wow

    • @alecaddd
      @alecaddd  5 ปีที่แล้ว

      Pretty awesome

  • @vikasgoswami4132
    @vikasgoswami4132 4 ปีที่แล้ว

    Hello Sir,
    My uploading button is not working here the code. please give me the solution for this jQuery(document).ready(function($){
    var mediaUploader;
    $('#upload-button').on('click',function(e){
    e.preventDefault();
    if( mediaUploader ){
    mediaUploader.open();
    return;
    }
    mediaUploader = wp.media.frames.file_frame = wp.media({
    title: 'Choose a Profile Picture',
    button: {
    text: 'Choose Picture'
    },
    multiple:false
    });
    });
    });
    and here is the eror in the console "Uncaught TypeError: Cannot read property 'frames' of undefined"...
    also this is the button but uploader is not working..

    • @chiroto
      @chiroto 3 ปีที่แล้ว

      Inside the enqueue file you need to add "wp_enqueue_media();" if there is an error with the "frames". It is included in the GitHub source files.

  • @ZaheerAbbasAghani
    @ZaheerAbbasAghani 9 ปีที่แล้ว +3

    PLZ Create Lessons for jquery too

  • @gilkatchko6482
    @gilkatchko6482 8 ปีที่แล้ว +1

    Thanks again for your great tutorials i'm making a realy great progress thanks to you!
    Promise that If i'll get rich by selling themes i'll buy you something from your amazon wish list XD
    If you dont mind i have a question about this tutorial, Why to define the media uploader on click event? i can define it on document ready and save the if statement and the duplicate of mediaUploader.open(), is there any reason you put it like this?
    THANKS!

    • @alecaddd
      @alecaddd  8 ปีที่แล้ว

      Hi, thank you so much for following and for your wonderful comment.
      I decided to define the media uploader on click because I want to avoid to define it if the user doesn't use it.
      If you hook the media uploader to a variable on document ready, you will always load the uploader every time the user access that page, even if he ends up not using it.
      It's not a big deal, and if your method works and you don't experience any performance issue, you're good to go :D
      Thanks for sharing your opinion and for the questions.
      Happy Coding!

  • @ValentinScarevnea
    @ValentinScarevnea 9 ปีที่แล้ว

    Very very nice video, it would be nice if you added next to Upload Image, and a Remove Image button. ^^

    • @ValentinScarevnea
      @ValentinScarevnea 9 ปีที่แล้ว +1

      It's just that i made the same, but to upload a LOGO image, and if there is a image, show image instead of TITLE, but once i upload a image i can just change it with another, but if there would be a delete image, then it can get back to simple TITLE text.

    • @alecaddd
      @alecaddd  9 ปีที่แล้ว +1

      Good call, I will add this to the next tutorial!
      Thanks for the suggestion.

  • @alexgrigoriev7133
    @alexgrigoriev7133 5 ปีที่แล้ว +1

    Thank man. You are really cool man)

    • @alecaddd
      @alecaddd  5 ปีที่แล้ว

      You're welcome :D

  • @VasilisKar
    @VasilisKar 8 ปีที่แล้ว +1

    Thanks a lot..

  • @alejandrar67
    @alejandrar67 7 ปีที่แล้ว

    Thank you!!

    • @alecaddd
      @alecaddd  7 ปีที่แล้ว

      You're very welcome

  • @fhelipeturati1483
    @fhelipeturati1483 6 ปีที่แล้ว +1

    Man, you´re good!

    • @alecaddd
      @alecaddd  6 ปีที่แล้ว

      Thank you so much :D

  • @guizlenaalvarado5458
    @guizlenaalvarado5458 8 ปีที่แล้ว +1

    Excellent!!!! :)

    • @alecaddd
      @alecaddd  8 ปีที่แล้ว

      Thank you so much!

  • @zkzks
    @zkzks 4 ปีที่แล้ว

    outstanding :)

  • @antari24
    @antari24 8 ปีที่แล้ว

    That was more than helpful! Thanks and have a sub ;)

  • @engr-mejba-ahmed
    @engr-mejba-ahmed 8 ปีที่แล้ว

    Awesome

  • @bonkedyan5627
    @bonkedyan5627 6 ปีที่แล้ว +1

    You rock

    • @alecaddd
      @alecaddd  6 ปีที่แล้ว

      You paper! 😜