Image displays in .HTML but not .PHP - php

I was working on a website and after finishing up the styling I wanted to start with the server-side. At first it was "index.html" and then the extension was changed to "index.php".
I loaded up XAMPP and went to run the website and one of the images failed to display. The image is actually a background image of a DIV (Bootstrap Jumbotron). I then changed the file extension back to .html and the image displays successfully. Then again back to .php and the image fails to display.
I then attempted to use a different image from the same folder (while the extension is .php), and it actually works. All other images work except this one image that fails to display.
Here is the CSS for the background image:
/* Does not work */
.jumbotron_image
{
background-image: url('../Images/lonely%20android.jpg');
background-repeat: no-repeat;
background-position: center center;
background-size: 100% auto;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
}
/* Works successfully with a different image */
.jumbotron_image
{
background-image: url('../Images/normal%20android.jpg');
background-repeat: no-repeat;
background-position: center center;
background-size: 100% auto;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
}
This is really weird and I have no idea what is causing it. I am thinking the fault lies with the image itself since all other images work. Any ideas are welcome.

Related

Image is not shown over the entire screen despite css code

On my website, I want to cover a page (not the home page) completely with a picture. It should completely fill the screen on every device. I have specially created a childtheme to handle this problem.
On my website, I want to create a gallery facility that greets the visitor with a picture across the entire screen. I've created a childtheme for it as already mentioned. I first tried once in the functions.php folder to set the content width to 100%. Unfortunately, this did not work. Then I tried it with all over the custom css field on my wordpress theme. That too did not work.
`element.style {
background-image: url(https://philippfalkenhagen.de/wp-content/uploads/2019/10/Reh-im-Mohnfeld-Startseite-1.jpg);
max-width: 100%;
height: 801px;
width: 100%;
}
With this code, it should actually be funkitoinieren as I want. Unfortunately I can not integrate it into my data. He does not fit in functions.php and he does not work as a custom css either.
// set default content width
if ( ! isset( $content_width ) ) {
$content_width = 680;
}
This code in the functions.php folder was my second attempt. I could not set the width to 100% and on all other values ​​she looked the same.
I expect that the picture under philippfalkenhagen.de/tiere-2`fills the entire screen. unfortunately it is not like that. When I used 100% of the second code, I could not even access my website until I reset the code.
Since you are dealing with a background and not a figure itself, try to use background-size: 100% 100% and background-repeat: no-repeat.
`element.style {
background-image: url(https://philippfalkenhagen.de/wp-content/uploads/2019/10/Reh-im-Mohnfeld-Startseite-1.jpg);
max-width: 100%;
height: 801px;
width: 100%;
background-repeat: no-repeat;
background-size: 100% 100%;
}
background-size: cover;
will help you to solve this issue.
updated:
`element.style {
background-image: url(https://philippfalkenhagen.de/wp-content/uploads/2019/10/Reh-im-Mohnfeld-Startseite-1.jpg);
max-width: 100%;
height: 801px;
width: 100%;
background-size: cover;
}
This is my functions.php folder:
https://we.tl /t-g7Mvc2EbC6
I suspect that I have to put the code here, but I do not know where.

PHP/ CSS changes needed

I am starting to dive into some PHP on my wordpress and I'm having some trouble
What I am trying to do:
1. add a button to the bottom of each image in an image gallery there are 4 rows and 4 columns
What I have done:
I created a child theme and copied my page.php file to my child them
added a div like this to my my php file: <div class="button"></div>
added the following CSS to my style.css
.page-id-482 div.button{
background-color: #4CAF50;
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
cursor: pointer;
border-radius: 15px;
}
I am stuck as to what I need to do to add a button to each image in the gallery. Every time I change the CSS I cant get the button to move. It currently sits where I placed it in the PHP. I need to change my CSS but I'm not sure how.
See image:

wordpress not getting current image path in css

I am developing my first plugin in wordpress and using background-image in style tag:
<head>
<style>
.remove {
border: solid;
background-image: url(icon-remove.jpg);
background-position: center center;
background-repeat: no-repeat;
cursor: pointer;
display: block;
font-size: 14px;
height: 20px;
padding-top: 40px;
text-align: center !important;
}
</style>
</head>
My plugin path is:
..www/wpsample/wp-content/plugins/sample
The Image file is present in same directory (/sample)
but it showing me error in console as 404 and the path it is looking for is
http://localhost/wpsample/wp-admin/icon-remove.jpg
How do I specify correct path for image file ?
You need to use the wp_enqueue_style command to tell WP where the file is:
wp_enqueue_style('myStyle' //--- name
//--- location of css file relative to this file
, plugin_dir_url(__FILE__).'css/myCSS.css'
, array()
);
This is required because people can install WP and set the folders to different names. The wp_enqueue_style will handle this for you.
Alternatively, embed the CSS within the same file.
If you want to use background-image in wordpress plugin, You should use relative css path to the stylesheet. Example:
background-image: url("../wp-content/plugins/sample/icon-remove.jpg");
Or you can add full url in url():
background-image: url("http://localhost/wpsample/wp-content/plugins/sample/icon-remove.jpg");
For more information read this link: W3
After trying many solution finally this works for me
background-image: url("<?php echo plugins_url().'/sample/icon-remove.jpg'?>");

Adding an image to bootstrap jumbotron with CodeIgniter Framework for PHP

I need help with adding an image, as the background, to a Bootstraps jumbotron in the Codeigniter Framework for PHP.
I currently can add an image to Codeigniter no problem with the following code:
<img src="<?php echo base_url('image/test.jpg'); ?>">
I can also use my CSS file to change the background of the jumbotron with the following code:
.jumbotron {
color: black;
text-align: center;
background-color: red;}
however, I am not sure how to get the css file to add my image to the background of the jumbotron. I have tried the following:
.jumbotron {
color: black;
text-align: center;
background-image: <?php echo base_url('image/test.jpg'); ?> }
.jumbotron {
color: black;
text-align: center;
background-image: url('image/test.jpg');}
.jumbotron {
color: black;
text-align: center;
background-image: 'image/test.jpg'}
Nothing that I try seems to work. I do have my images folder under the project and not in the application folder. I can get the images to display anywhere on my page-that is not the problem. But getting them as the background in the jumbotron does not work.
The easiest thing is to apply it in your view to the Jumbotron.
Try something like this in your view:
<div class="jumbotron" style="background-image: url('<?= base_url('image/test.jpg'); ?>')">
...
</div>
You can still do the rest of your styling for the background image e.g. background-size in CSS for your jumbotron.
CSS files won't be parsed by PHP unless you specifically change your server to parse them or output them from PHP files with a CSS extension.
The background image when manually specified in CSS in your example wouldn't have worked because you had a relative path to specify the image location. E.g. the browser would have looked for the picture at /css/image/test.jpg rather than /image/test.jpg. If you specif background-image: url('/image/test.jpg') in your CSS it should work.

Draw an image on web site at the end of the script

I have a little problem. At the end of my R script I create an image .png as output. I wanna show this image on my website but sometimes it is drawn, sometimes it is not drawn. I don't understand how it is possible. I`ll put my code:
I insert the image in a div with this features:
#diagramm {
position: relative;
border: 2px solid #333;
border-color: #6495ED;
width: 820px;
height: 370px;
margin: 2px auto;
margin-top: 2em;
background-image: url("/home/daniele/public_html/appweb2013/venn_final/fungo_final.png");
}
Where is the mistake? Can I use a better method?
This is CSS, it only puts specific design rules for an element that has the id diagramm.
So what you've posted is not code so to speak.
In what way do you generate the output? When? what does the user do to generate it etc.
Do you have any javascript or html code you can show?

Categories