Comments (8)
could it have to do with the extra space after ?>
and before the closing quote?
from parallax.js.
I'm also having an issue with using Post Thumbnails in Wordpress.
@kosvrouvas the problem you have is that the_post_thumbnail() returns an image element. You'll need to get the attachment URL of the post thumbnail like so:
$url = wp_get_attachment_url( get_post_thumbnail_id( $post->ID ) );
Hope that helps.
Unfortunately for me the image isn't getting added to the body tag in my document at all. It has worked fine for me previously but now using data attributes there's nothing being added.
from parallax.js.
No, @NateFlynn still can't get it work... Thank you though!
from parallax.js.
@kosvrouvas did you echo the value of $url into the data-image-src attribute? It may return as an array so if that doesn't work try echo $url[0] instead.
ie:
$url = wp_get_attachment_url( get_post_thumbnail_id( $post->ID ) );
<div class="headerwrap parallax-window" data-parallax="scroll" data-image-src="<?php echo $url; ?>">
</div>
or
<div class="headerwrap parallax-window" data-parallax="scroll" data-image-src="<?php echo $url[0]; ?>">
</div>
Hope this one works!
from parallax.js.
I'm not a wordpress user, so I really can't help much on this one, but like @NateFlynn commented, and based on the WP documentation on the_post_thumbnail()
it would appear this is returning a full <img />
tag and not a simple URL.
You'll need to use something like:
<?php
list($src, $width, $height) = wp_get_attachment_image_src(get_post_thumbnail_id(), 'full' );
?>
<div class="headerwrap parallax-window" data-parallax="scroll" data-image-src="<?php echo $src; ?>" data-natural-width="<?php echo $width; ?>" data-natural-height="<?php echo $height; ?>">
You may or may not need to add a parameter to the get_post_thumbnail_id()
function. I don't really know how it works in this context and of course, I cannot test this since I don't have a wordpress site to mess around with, but this is based on the documentation found here:
http://codex.wordpress.org/Function_Reference/wp_get_attachment_image_src
from parallax.js.
Ηi, what @NateFlynn said worked! Thanks! Haven't tested @mikegreiling's answer but good to know, thank you too!
from parallax.js.
glad to hear it
from parallax.js.
@kosvrouvas glad you got it working!
In other news, mine's also working now as well... turns out it was a bug in my minification script causing parallax to be called before jQuery.... doh!
from parallax.js.
Related Issues (20)
- text-align affects background location
- .trigger('resize').trigger('scroll') not working HOT 3
- iOS 13 issue with inner HTML HOT 2
- CDN version outdated HOT 2
- Using a semi-transparent container over background image lag HOT 1
- Resize does the exact opposite
- Using "sticky"element offsets parallax container HOT 3
- Add alt attribute? HOT 3
- Vanilla JS version? HOT 2
- V. 1.5 works on mobile devices, but this v. 2.0 does not?
- Flash on image load
- is it possible to put text on the images with html for the effect? HOT 2
- Setting speed to negative value does not reverse parallax effect
- Feature request: Support responsive images
- Parallax 2.0 not working on mobile HOT 1
- Does not work with Angular Universal HOT 2
- parallax.js limits width?! HOT 1
- Feature Request: Can you have a video parallax as well?
- Parallax is not a function
- Doesn't work properly when using it with Bootstrap
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from parallax.js.