WordPress.org

Ready to get started?Download WordPress

Forums

WP-Cycle
ALT text for wp-cycle (8 posts)

  1. Wedding Photographer Devon
    Member
    Posted 2 years ago #

    is there away for the alt text to be included for the images in a wp-cycle gallery?

    http://wordpress.org/extend/plugins/wp-cycle/

    wedding photography in Devon

  2. kikolani
    Member
    Posted 2 years ago #

    I'm have the same question. I'm working on a Phoenix wedding photography site using the Genesis framework (Legacy Theme), and the only images missing the alt text on the homepage are the ones in my WP-Cycle rotator. Would love to get that fixed!

    UPDATED: The temporary fix is to go into the Plugins editor for WP-cycle, do a CTRL-F to find alt, and when you find the line:

    echo '<img src="'.$data['file_url'].'" width="'.$wp_cycle_settings['img_width'].'" height="'.$wp_cycle_settings['img_height'].'" class="'.$data['id'].'" alt="" />';

    Enter your alt text there. Granted, it will be the same for all of your images, but at least you'll have something.

  3. Marventus
    Member
    Posted 2 years ago #

    Hi there,

    Since the plugin works with uploaded images and not with post images, the only way to include dynamic alts in your images would be to add them as an option inside the plugin itself.
    I tried this on one of my test blogs and it is working well. The changes needed are not very big, but you have to be extremely careful while editing the code so as not to break it.

    Step 1:
    Backup your plugin files in case something goes wrong during the editing and you have to go back to the original version.

    Step 2:
    Open the file wp_cycle.php in a text or HTML editor.

    Step 3:
    Look for:

    $wp_cycle_images[$time] = array(

    Add a comma at the end of this line

    'image_links_to' => ''

    so it looks like this:

    image_links_to' => '',

    Insert the following line right below that one:

    'alt_text' => ''

    Step 4:
    Look for this line:

    <th scope="col">Image Links To</th>

    There should be two instances of that line. For each instance, insert the following line right under it:

    <th scope="col">Alt Text</th>

    So that this line:

    <th scope="col" class="column-slug">Actions</th>

    comes after your new line. End result should be:

    <th scope="col" class="column-slug">Image</th>
    <th scope="col">Image Links To</th>
    <th scope="col">Alt Text</th>
    <th scope="col" class="column-slug">Actions</th>

    Step 5:
    Look for this line of code:

    <td><input type="text" name="wp_cycle_images[<?php echo $image; ?>][image_links_to]" value="<?php echo $data['image_links_to']; ?>" size="35" /></td>

    Insert the following line right under it:

    <td class="column-slug"><input type="text" name="wp_cycle_images[<?php echo $image; ?>][alt_text]" value="<?php echo $data['alt_text'];?>" size="35"/></td>

    Step 6:
    Look for this line of code:

    $input[$key]['image_links_to'] = clean_url($value['image_links_to']);

    Insert the following line right under it:

    $input[$key]['alt_text'] = esc_textarea($value['alt_text']);

    Step 7:
    Look for this chunk of code:

    foreach((array)$wp_cycle_images as $image => $data) {
    if($data['image_links_to'])
    echo '<a href="'.$data['image_links_to'].'">';
    echo '<img src="'.$data['file_url'].'" width="'.$wp_cycle_settings['img_width'].'" height="'.$wp_cycle_settings['img_height'].'" class="'.$data['id'].'" alt="" />';
    if($data['image_links_to'])
    echo '</a>';
    echo $newline;
    }

    And replace it with this one:

    foreach((array)$wp_cycle_images as $image => $data) {
    if($data['image_links_to']){
    echo '<a href="'.$data['image_links_to'].'">';
    }
    echo '<img src="'.$data['file_url'].'" width="'.$wp_cycle_settings['img_width'].'" height="'.$wp_cycle_settings['img_height'].'" class="'.$data['id'].'"';
    if($data['alt_text']){
    echo 'alt="' .$data['alt_text'].'"';
    }
    echo ' />';
    if($data['image_links_to']){
    echo '</a>';
    }
    echo $newline;
    }

    Presto, you are done! You can now assign custom alt texts to each of your images from the plugin options.

    Here is a pastebin link to the modified wp_cycle.php file just in case.

    Cheers!

  4. kikolani
    Member
    Posted 2 years ago #

    Wow, thanks Marventus! I'll add this in!

  5. Marventus
    Member
    Posted 2 years ago #

    You are welcome! ;-) Let me know if you encounter any problems with it. You might want to share this with the plugin author: he might consider including this feature in his plugin, since alt texts are extremely useful for search rankings and SEO in general.
    Cheers!

  6. cuongnguyen208
    Member
    Posted 1 year ago #

    I did not get on that when I copied the above file
    Introduction: http://giaiphapsieuthi.net
    need help from you

  7. isle2isle
    Member
    Posted 1 year ago #

    When I made my demo site live I moved all my files from the demo directory down into the main URL directory. Everything worked fine, but the wpCycle is still linking to the files in the old directory which I eventually want to delete. Is there a way to edit the image URLs manually so I don't have to re-upload all the images and reset everything?

  8. Marventus
    Member
    Posted 1 year ago #

    @cuongnguyen208: I see an alt value in all your slider images.

    @isle2isle: Please open a new thread with your problem, since it has very little to do with the OP's.

    Cheers!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags