Forum Replies Created

Viewing 9 replies - 16 through 24 (of 24 total)
  • Thread Starter blufragola

    (@blufragola)

    Hello again.
    I read your instruction about gallery filter.
    I tried to filter my custom field imgs_field this way:

    <?php
    $gallery_of_images = get_custom_field('imgs_field:gallery;');
    print_custom_field($gallery_of_images, '<img height="[+height+]" width="[+width+]" src="[+guid+]" title="[+post_title+]" alt="[+alt+]" class="cctm_image" id="cctm_image_[+i+]"/>');
    ?>

    I don’t know where I’m doing wrong but the output says:
    The ["387","388"] field is not defined as a custom field.

    Probably I’ve misunderstood how to use the code. ??

    Thread Starter blufragola

    (@blufragola)

    Got it! I used array_shift and then foreach.

    I’ve updated CCTM…now I wait for your documentation about the new “gallery” filter.

    Thread Starter blufragola

    (@blufragola)

    For now I have tried to change my code using foreach and array_slice() to separate the output for the first item of the array from that for the others. I’m not very satisfied about the result, because I’ve had to repeat a portion of the code, but for now it’s a little step forward.

    Thread Starter blufragola

    (@blufragola)

    Another (silly) question: what is the best way to upgrade to 0.9.5.6 version without messing up?
    Thank you

    Thread Starter blufragola

    (@blufragola)

    First of all, thank you.

    About the “for loop”, I’m using it because I have to separate the first item from the others (I haven’t pasted the whole code because it is very long): only the first one must be “medium” and not “thumbnail”, so I can identify it as $array_of_images[0]. I don’t know how to do this with the “foreach loop”. Is there a way? ??

    I look forward to reading your docs about “galley filter”. It seems to be very interesting and useful for my purposes.

    Thread Starter blufragola

    (@blufragola)

    You’re the Best! Thank you for the example and your suggestions.

    I want to share my code (it could be useful for someone else):

    <?php
    $array_of_images = get_custom_field('imgs_field:to_array');
    if($array_of_images[0]) {
    for ($i=0;$i<count($array_of_images);$i++){
    $img_orig = CCTM::filter($array_of_images[$i], 'to_image_src');
    $img_small = wp_get_attachment_image($array_of_images[$i], 'thumbnail');
    }
    ?>
    <div class="img_single">
    <a href="<?php print $img_orig; ?>" rel="lightbox_or_whatever" title="">
    <?php print $img_small; ?>
    </a>
    </div>

    imgs_field = is the name of the repeatable custom field for images
    $img_orig = it returns the path for the original uploaded image
    $img_small = it returns something like this:
    <img class="attachment-thumbnail" width="[the value of thumb width]" height="[the value of thumb height]" title="[the title of the image as written in Media library]" alt="[the alternative text as written in Media library]" src="[the path of the thumbnail]">

    Now I can organize my gallery, and set it up for lightbox, but I still have a problem: I’m trying to “extract” the title value from wp_get_attachment_image(), because I need to put it as an attribute of the <a> tag, not <img> (for lightbox).

    I’ve found something about wp_get_attachment_image_attributes() but I still don’t know how to use it and if it could be useful for my purposes.

    Thank you again for your help.

    Thread Starter blufragola

    (@blufragola)

    Hello.
    Thank you for your suggestion.
    Unfortunately, I can’t figure out how to combine Example 4 (Retrieving Multiple Images) with Example 5 (All an Image’s Data): I made many tests but I don’t get how to write the correct code to make it work. ??
    Besides, I wonder if it is the correct way to get “alt” and “title” values from the image files as stored in Media library.

    I need to build a lightbox gallery with multiple images uploaded by a repeatable image custom field. I put the code in the template, and I’m trying to create with the correct code, the following scenario:

    <a href="path_to_original_img" rel="lightbox_or_whatever" title="title_from_media_library_img_details_for_lightbox_caption">
    <img src="path_to_thumbnail_or_medium_image"  width="width_of_thumbnail_or_medium_image" height="height_of_thumbnail_or_medium_image" alt="alt_from_media_library_img_details"/>
    </a>

    I thought also about putting 2 custom text fields after the one for the image, one for the text I want to insert as “title”, and one for the one I want to use as “alt”. It would be the PERFECT solution for me, because I’ll also have to translate these data, BUT
    I’d need this group of 3 custom fields to be repeatable, all together, and I haven’t got if it’s possible or not.

    I’ll go on to look for a solution by myself but I’ll appreciate if someone could help me.
    Anyway, thank you.

    Thread Starter blufragola

    (@blufragola)

    The website that I am building is in WordPress, and it’s almost finished, so I’m not going to change system at the point I am now. Maybe for the next project I could consider MODX as an alternative. So, thank you for your suggestion. It sounds very interesting!
    I’ve just found some online documentation in my language (italian) and I’m going to explore this CMS as soon as possible.

    Thread Starter blufragola

    (@blufragola)

    Got it!
    It’s the best thing to do. I’m going to try immediately.
    Thank you very much!
    I’m pretty new to WordPress (I have got experience with Joomla) and I’m still learning.

Viewing 9 replies - 16 through 24 (of 24 total)