Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

use lightview on the mainpage with fullscreen theme WordPress

  • SOLVED

Hi everybody,

i´ve the following issue. i like to view the media which is included in an article by clicking on the article thumbnail with the lightview plugin.
the main problem is, that i am not able to get the url of the media in the article to replace the current link wich is targeted to the permalink of the article.

normaly the link is like that:


<a href="<?php the_permalink() ?>" rel="set[myset]" title="Permanent Link to <?php the_title_attribute(); ?>"><?php get_the_image( array( 'custom_key' => array( 'thumbnail' ), 'default_size' => '320x320', 'width' => '320', 'height' => '320', 'link_to_post' => false ) ); ?></a>


to get an idea what i want, here the link to my site:

http://www.sichtweiser.com

can anybody help me??

Answers (3)

2010-07-18

wjm answers:

Hi,
this code will list all the attachments you have associated to a post.

all the information related to the attachment is in the loop in tha $attachment var.
in this example i show you how to display the links, using the_attachment_link() template function.

inside the loops there are many variables available for you such as: $extension, $file_name, $file_type, $link;


<?php
//originally based on http://www.wprecipes.com/how-to-show-wordpress-post-attachments
$args = array(
'post_type' => 'attachment',
'numberposts' => -1,
'post_status' => null,
'post_parent' => $post->ID
);
$attachments = get_posts($args);
//print_r($attachments);
echo '<ul>';
foreach ( (array)$attachments as $attachment) {
$link = wp_get_attachment_url( $attachment->ID );
$pathinfo = pathinfo($link);
$extension = $pathinfo['extension'];
$file_name = $pathinfo['filename'].'.'.$pathinfo['extension'];
$file_type = $attachment->post_mime_type;

echo $extension, $file_name, $file_type, $link;
echo '<li>';
the_attachment_link($attachment->ID, false);
echo '</li>'."\n";
}
echo '</ul>';
?>


let me know if it works for you.
- wjm


momsen comments:

that looks fantastic! now i´ve got the problem that i don´t know how to paste the function into the link. i tried this:

<a href="<?php the_attachment_link($attachment->ID, false) ?>" class"lightview" title="Permanent Link to <?php the_title_attribute(); ?>">

but this doesnt work. something in the function destroyes the a href tag...


wjm comments:

please, provide the output html to see what could be causing it to break


momsen comments:

here is the file


momsen comments:

ähm sorry

you can download it here:

[[LINK href="http://www.sichtweiser.com/upload/html.zip"]][[/LINK]]


momsen comments:

okay, something went wrong with the upload and the link.... so again

http://www.sichtweiser.com/upload/html.zip


wjm comments:

sorry momsem, but you have no idea what you are doing with your html and php,
you changed what i provided you and that is never going to work.

please raise your prize if you want me to provide you with the right code for your home.php
thanks
- wjm


momsen comments:

ok, i raised the price. looking forward to the right code!
thank you!!!!!


wjm comments:

Hi Momsen:
here's a fixed version of what you need.
i dont quiet comprehend exactly what you try to do here but i fixed the logic.
http://wordpress.pastebin.com/SCM47uw9

let me know if you need anything else.
- wjm


2010-07-18

Oleg Butuzov answers:

<?php
$size = 'large';
wp_get_attachment_image_src($image_ID, $size, false);


image_ID is id of the attached media.

if you want to use featured images use
<?php
$size = 'large';
$image_ID = get_post_meta($post->ID, '_thumbnail_id', true);
$img = wp_get_attachment_image_src($image_ID, $size, false);


$img is array, first leement is url, second and third is image dimensions


momsen comments:

but unfortunately not for me...


momsen comments:

thank you for the fast reply.

hmm,..sounds good. but the in the articles there aren´t just images there are also videos.
and how do i get the link working?


Oleg Butuzov comments:

use wp_get_attachment_url for that case... one argument is id of the image.


momsen comments:

everything sounds logical, but i am really not so familiar with wordpress. could you maybe give me the whole link or rather the whole code which i have to use?


Oleg Butuzov comments:

ok. lets stop. can you describe a full task and are you able to work with php/html code?

2010-07-18

Rashad Aliyev answers:

Hello I want to give you some suggestion:

1- http://wordpress.org/extend/plugins/lightbox-2/
See example: http://stimuli.ca/lightbox/


2- http://wordpress.org/extend/plugins/lightbox-gallery/
Screenshots: http://wordpress.org/extend/plugins/lightbox-gallery/screenshots/

P.S: I don't know 1st or 2nd one will work via 3.0 or not. The plugins page doen't contain any information about this.

3- http://wordpress.org/extend/plugins/lightbox-plus/ (BEST CHOISE)
Screenshots: http://wordpress.org/extend/plugins/lightbox-plus/screenshots/
P.S: working with wp3.0
you can see here how it's working (using it on plugin page) : http://www.23systems.net/portfolio/

4-http://wordpress.org/extend/plugins/photo-lightbox/
Screenshots: http://wordpress.org/extend/plugins/photo-lightbox/screenshots/

best regards,