Giter Site home page Giter Site logo

Comments (8)

mikegreiling avatar mikegreiling commented on July 22, 2024

could it have to do with the extra space after ?> and before the closing quote?

from parallax.js.

FlynnTechTV avatar FlynnTechTV commented on July 22, 2024

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.

kosvrouvas avatar kosvrouvas commented on July 22, 2024

No, @NateFlynn still can't get it work... Thank you though!

from parallax.js.

FlynnTechTV avatar FlynnTechTV commented on July 22, 2024

@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.

mikegreiling avatar mikegreiling commented on July 22, 2024

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.

kosvrouvas avatar kosvrouvas commented on July 22, 2024

Ηi, what @NateFlynn said worked! Thanks! Haven't tested @mikegreiling's answer but good to know, thank you too!

from parallax.js.

mikegreiling avatar mikegreiling commented on July 22, 2024

glad to hear it

from parallax.js.

FlynnTechTV avatar FlynnTechTV commented on July 22, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.