Wordpress Themes - WP Forum at BFA

Wordpress Themes - WP Forum at BFA (http://forum.bytesforall.com/index.php)
-   New Versions, & Updating (http://forum.bytesforall.com/forumdisplay.php?f=12)
-   -   Automatically adding text below all images (http://forum.bytesforall.com/showthread.php?t=1212)

myfacegraphics Apr 10, 2009 01:03 PM

Automatically adding text below all images
 
Hi Flynn, seems you are in demand. :)

I'd like to hire you as soon as possible for a quick mod to my site.
I own www.myfacegraphics.com and have installed your theme.

Basically what I am trying to do is emulate: www.myspacegraphics.co.uk in terms of functionality.
I need to have it so that the "embed code" for each image is displayed beneath each image.

I have been looking at the www.gigya.com widget integration, without success - it's handy because it can post images/content to a variety of social networking websites.

Are you available to help?

Possibly getting the gigya working, or simply getting it so that the embed code is automatically added to each blog post.

I have spent all day todaay working with nextgen image gallery.

Quite like showing things one after the other in a single post, as per here: http://myfacegraphics.com/testing-gallery/ but need to get the code beneath each one (Id like to be able to make sure the right "alt" and description is used for marketing purposes).

As it currently stands if you click an imageit brings up a texarea with the embed code in it, although its been manually added... so yes... what I really need is to be able to add an image to a post, and then use a function which knows the image, knows its location and sets it into an embed code of its own under the image.

Im also going to add adsense under each one too, or at least per page.. might be good for another discussion elsewhere.


so yes Id like to have it for all images on all posts (but a check box to cancel it from time to time would be useful, in case I want to write a regular blog - heck!) :p)

and if you can have an "alt/description" added so that can be added somehow.
Thanks flynn

shaun

Thanks
Shaun

Flynn Apr 10, 2009 06:02 PM

Add this to the bottom of functions.php without causing blank lines or spaces:

PHP Code:

<?php
function bfa_add_code_below_images_callback($matches) {
return 
'<img'.$matches[1].'src="'.$matches[2].'"'.$matches[3].'>
<textarea class="textbox" onclick="this.select(); this.focus();" rows="1" cols="90" 
style="overflow: hidden; height: 30px;" name="myspace-graphics">
<center><a href="http://www.myspacegraphics.com/images/" target="_blank" title="Myspace Graphics">
<img src="'
.$matches[2].'" border="0" alt="Myspace Graphics">
</a><br><b><font face="Arial" size="2"><a href="http://www.myspacegraphics.com/" title="Myspace Graphics">Myspace Graphics</a>
</font></b></center></textarea>'
;
}     
function 
bfa_add_code_below_images($post_body_content) {
$post_body_content preg_replace_callback("|<img(.*?)src=\"(.*?)\"(.*?)>|","bfa_add_code_below_images_callback",$post_body_content);
return 
$post_body_content;
}
add_filter('the_content''bfa_add_code_below_images');
?>

This would add a code area below every image on every page. The images should not be linked and should have no caption.

myfacegraphics Apr 11, 2009 12:22 AM

Hiya flynn it generated an error: http://www.myfacegraphics.com/

I got to the file in the wp_includes folder went to the very last ?> then hit the return key to get to the next line and pasted in that code in its entirety

EDIT: I took it out of there and then went and added it to the functions.php inside the atahualpa folder and got a similar error message..

thanks
shaun

Flynn Apr 11, 2009 04:50 AM

Sorry I left a piece of code in there, with which I was trying something.

I updated the code above with my working version. Please try again.

myfacegraphics Apr 11, 2009 05:35 AM

Thanks.. almost there.. http://myfacegraphics.com/category/myspace-tv-cartoons/

when i try to click to copy the text it brings up the image in a new window when i try to cl;ikck it again it brings me right to the gif file

seems the textarea is clickable unless im doing something wrong?

Thanks again!

shaun

Flynn Apr 11, 2009 06:28 PM

No but I mentioned that the images shouldn't be linked. So you'll have them all linked? Or just a few? What about captions? Linked with captions? Each of these four versions needs a separate piece of code. I'll update this tomorrow, please feel free to remind me if I don't.

myfacegraphics Apr 12, 2009 12:14 AM

Hi Flynn... no need I forgot to un-link :-)

After doing this it seems at the moment to work just fine - many thanks!

I'll be sure to come back to you if I need any more revisions done to my site in general (most likely :p)

Take care, thanks for working on my site.

Much appreciated

Shaun


All times are GMT -6. The time now is 08:03 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.