Viewing 6 replies - 1 through 6 (of 6 total)
  • 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.

    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!

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

    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!

    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?

    @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!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘ALT text for wp-cycle’ is closed to new replies.