Reputation: 361
Well the question is pretty clear. How could i use text from a placeholder e.g from the below script. I've been searching a lot for this and haven't found a solution. Your help would be appreciated.
Theme-options.php file:
<input type="text" placeholder="1.jpg" name="director_image1"
value="<?php print get_option('director_image1');
?>" />
I am using functions.php to retrieve the file and then echoing it inside the header:
var image1=<?php $image1 = get_option('director_image1');?>
<?php if( $image1) : ?>
<?php echo "'".$image1."';"; ?>
<?php endif; ?>
I am then using the image inside a javascript file.Could you please help me out?
Upvotes: 1
Views: 181
Reputation: 17268
In the PHP code add an id to the image element. Use getElementById
to retrieve the img element.
$image1 = of_get_option('director_image1');
if ($image1) echo "<img id=\"dir_image\" src=\"" . $image1 . "\" />";
var image1 = document.getElementById('dir_image');
if (image1)
{
// do something ...
}
Upvotes: 2