I am trying to use some rollovers to jQuery. The problem is that the image source has to use some PHP code.
If I inline it with Javascript, then it works:
$ thumburl variable is exactly the same; the thumbnail of the special thumbnail URL thumbnail bit converts when it changes I get a B & W and colorful images url which is swapped. I am using WordPress because I want to use php instead of just specifying image protection because size and color conversion Automatically done for user
The first question is, inline like code? Second, I'm struggling to write a jQuery function for the rollover due to PHP. I think this would be:
< Pre> $ (document) .ready (function () {$ ('. Project img'). Hover (funcation () {this.src = '& lt ;; php thumbGen ($ thumburl, 300,0, 1,0,1);?; ';';}, Function () {this.src = '& lt ;? php thumbGen ($ thumburl, 300,0,1, 0,1) ;; & gt; ;});
But I do not know where this is included: $ thumburl = wp_get_attachment_url (get_post_thumbnail_id ($ post-> id));
You can also add php and jquo in one ?
Thanks
You can make PHP a bit simpler in this way: < / P>
& lt; A href = "& lt ;? php the_permalink () ;? & gt;" & Lt ;? Php $ thumburl = wp_get_attachment_url Get_post_thumbnail_id ($ post-> ID)) ;? & Gt; & Lt; Img src = "& lt ;? Php thumbGen ($ thumburl, 300,0,1,0,1) ?? & gt;" Data-hover = "& lt ;; php thumbGen ($ thumburl, 300,0,1,0,0) ?? & gt;" /> & Lt; / A & gt;
Then do something like this in jQuery, using that:
$ (function () {$ ('IMG'). ) {$. Data (this, 'orig', this.src);}}. Hover (function () {this.src = $ (this) .attr ('data-hover');}, function () { This.src = $ .data (this, 'orig');});});
Uses the original src
for each image , Then we grab the new src
attribute on the hover, that's what we store in the data-hover
(the data we have created). Not, and when we do we pavilion original src
to receive and restore it.
Comments
Post a Comment