Error generating variable based on Youtube ID
-
Hey guys,
First of all, thank you for your amazing work with this plugin.
I think I found a bug in the generator of the $selector variable you are using to generate an element id for the player.
You are doing that based on the youtube video ID and you are assuming the ID is the last 4 characters of the youtube video.There are situations where the youtube video has special characters (even in the last 4 characters). If that happens your shortcode will fail because you have a JS variable that is the $selector and variables can’t have special characters.
Example:
– Youtube ID: ybCsxtpp-Q
– $id = ybCsxtpp-Q
– $selector = pp-QIn this case you will see a JS error:
“Uncaught SyntaxError: Missing initializer in const declaration”
because the const name is “pp-Q”.
In my option it’s ok to have “-” in the selector variable but we can’t use it as a variable name.
Other option is to use another approach to extract the $id where you can ensure the variable won’t have special characters.Thank you again for your amazing contribution.
- The topic ‘Error generating variable based on Youtube ID’ is closed to new replies.