• Resolved nuclearping

    (@nuclearping)


    Please consider removing the hardcoded “px” appendix from the “max-width” clause in line 182. This allows for more user-flexibility, because you can use width=”70%” or width=”2em”, etc.

    Simply change …

    if(!empty($width)){
    	$style = <<<EOT
    		<style>
    		#$player {
    			max-width:{$width}px;
    		}
    		</style>
    	EOT;
    }

    … to …

    if(!empty($width)){
    	if (is_numeric($width[strlen($width) - 1]))
    	{
    		$width .= "px";
    	}
    	$style = <<<EOT
    		<style>
    		#$player {
    			max-width:{$width};
    		}
    		</style>
    	EOT;
    }

    This will only add “px” to “$width” if the last character of width is numeric. Otherwise it will use the user’s input directly.

    • This topic was modified 5 years, 11 months ago by nuclearping.
    • This topic was modified 5 years, 11 months ago by nuclearping. Reason: Fixing typos
Viewing 7 replies - 1 through 7 (of 7 total)
  • mmm i tried that but broke my site ??
    …have to remove the plugin, is a nice idea, but might be something wrong with that code

    Thread Starter nuclearping

    (@nuclearping)

    Please post the modified code. I have it running here and it works fine. ??

    Hello,
    Just pasted this code in but it gives me a 500 error…
    Something isn’t right with that code. Could you please revise it? because it would be really nice to use it.

    Thread Starter nuclearping

    (@nuclearping)

    Please copy & paste the whole code of the file to Pastebin.com, so that I can have a look at the whole thing. It works fine for me here, so I suspect some copy & paste error. ??

    Thread Starter nuclearping

    (@nuclearping)

    You have an additional unnecessary closing brace }

    	EOT;
    } // <--
        }
    

    And the EOT; must be at the start of the line. But that’s an error in my original post, which I cannot edit anymore.

    The correct modification should look like this:

    if(!empty($width)){
    	if (is_numeric($width[strlen($width) - 1]))
    	{
    		$width .= "px";
    	}
    	$style = <<<EOT
    		<style>
    		#$player {
    			max-width:{$width};
    		}
    		</style>
    EOT;
    }

    However, I also found out that the Plugin ignores the “class” parameter in the shortcode, even though you can pass it and fixed that too.

    I uploaded my modified version to Pastebin: https://pastebin.com/MbCW4ti9

    Hi NuclearPing,

    Works like a charme!!!
    Thanx!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Tweaks to “width”’ is closed to new replies.