WordPress.org

Ready to get started?Download WordPress

Forums

Thumbnail name, resizing and custom fields (1 post)

  1. fefo1983
    Member
    Posted 2 years ago #

    Hi everybody,

    I have the following problem, and I really don't know how to solve it. I have a basi experience in PHP programming and a good one in WordPress hacks, but this time I really don't know how to do it!

    Basically I have a website I'm developing for a friend. He has got an antiques gallery in Paris and needs to show the objects he's selling through the website. I've created the full structure and the single object pages, where I need to load the thumbnails in a certain way in order to use the zoom plugin you see live.

    To see a basic object page click here: http://demo.liquidfactory.it/tobogan/objets/g-durand-table-de-style-louis-xv/

    As you can see, the system loads a main image and several thumbnails thanks to the following piece of code I made:

    <?php
    			$immagine = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
    			$immagine_ridotta = substr($immagine, 0, -4);
    			$url_completo_1 = get_post_meta($post->ID, 'thumbnail-1_value', true);
    			$url_ridotto_1 = substr($url_completo_1, 0, -4);
    			$url_completo_2 = get_post_meta($post->ID, 'thumbnail-2_value', true);
    			$url_ridotto_2 = substr($url_completo_2, 0, -4);
    			$url_completo_3 = get_post_meta($post->ID, 'thumbnail-3_value', true);
    			$url_ridotto_3 = substr($url_completo_3, 0, -4);
    			?>
    			<a href="<?php echo $immagine ?>" class="MagicZoom" id="gallerie"><?php the_post_thumbnail('objet'); ?></a>
                <a href="<?php echo $immagine ?>" rel="zoom-id:gallerie" rev="<?php echo $immagine_ridotta ?>-980.jpg"><img src="<?php echo $immagine_ridotta ?>-230.jpg" class="thumbnail-objet" /></a>
                <?php
    			if (!($url_completo_1 == NULL))
    			{
    			?>
                <a href="<?php echo get_post_meta($post->ID, 'thumbnail-1_value', true) ?>" rel="zoom-id:gallerie" rev="<?php echo $url_ridotto_1 ?>-980.jpg"><img src="<?php echo $url_ridotto_1 ?>-230.jpg" class="thumbnail-objet" /></a>
    			<?php
                }
                ?>
                <?php
    			if (!($url_completo_2 == NULL))
    			{
    			?>
                <a href="<?php echo get_post_meta($post->ID, 'thumbnail-2_value', true) ?>" rel="zoom-id:gallerie" rev="<?php echo $url_ridotto_2 ?>-980.jpg"><img src="<?php echo $url_ridotto_2 ?>-230.jpg" class="thumbnail-objet" /></a>
                <?php
                }
                ?>
                <?php
    			if (!($url_completo_3 == NULL))
    			{
    			?>
                <a href="<?php echo get_post_meta($post->ID, 'thumbnail-3_value', true) ?>" rel="zoom-id:gallerie" rev="<?php echo $url_ridotto_3 ?>-980.jpg"><img src="<?php echo $url_ridotto_3 ?>-230.jpg" class="thumbnail-objet" /></a>
                <?php
                }
                ?>

    As you can see I had to "strip off" the .jpg part from the filename, modify the media.php file in order to give the automatically resized images in WordPress just the width in the filename (namefile-230.jpg and not namefile-230xNNN.jpg) and I'm able to load everything properly.

    The problem is: I need to adjust the thumbnail for some image and when I do that, the system saves the image adding a string after, like this:

    6-appliques-Linke2-230

    after adjusting the thumbnail becomes:

    6-appliques-Linke2-e1329322686940-230

    Now the possible solutions are two:

    1) I force the system to overwrite the old thumbnail (and I don't know how to do it, but I guess I have to modify it on media.php)

    2) I force the system to look for the newer image named like that ignoring that string (and I don't even know it's possible in PHP!)

    I hope to find someone who can help me, even on a paid basis.

    Thanks a lot.

Topic Closed

This topic has been closed to new replies.

About this Topic