WordPress.org

Forums

WP-Cycle
[resolved] Image re-order (14 posts)

  1. vitamineg
    Member
    Posted 1 year ago #

    Is there a way to re-order images without deleting and re-uploading the images?

    Thanks

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

  2. Gyan Gaurav
    Member
    Posted 1 year ago #

    Hi vitamineg !!

    The wp-cycle plugin does not support this reordering facility.. I just tried what you're looking for..And i just succeed in it.. all you need to do is to add some codes in your wp-cycle.php file in the plugin directory.

    I will be happy to assist you.. But let me first know if you have already got this issue resolved ?

  3. cubecolour
    ɹoʇɐɹǝpoɯ
    Posted 1 year ago #

    Gyan, if you can post your solution, it would help anyone else who is looking for this and arrives here when searching.

  4. Gyan Gaurav
    Member
    Posted 1 year ago #

    Ok.. There's my take on this one.

    To do so I have added one field namely "order" in the image data..
    find this code in wp-cycle.php in the plugin directory..

    $wp_cycle_images[$time] = array(
    		'id' => $time,
    		'file' => $file,
    		'file_url' => $url,
    		'thumbnail' => $thumbnail,
    		'thumbnail_url' => $thumbnail_url,
    		'image_links_to' => ''
    	);

    and add here another line 'Order' => '' so that it become like ..

    $wp_cycle_images[$time] = array(
    		'id' => $time,
    		'file' => $file,
    		'file_url' => $url,
    		'thumbnail' => $thumbnail,
    		'thumbnail_url' => $thumbnail_url,
    		'image_links_to' => '',
    		'Order' => ''
    	);

    then we need to make it appear in the admin section .. so find the <thead> and <tfoot> section here..
    and in the <tr> section of both of these <thead> and <tfoot> add a line
    <th scope="col">Order</th> this will make it appear in the settings page.
    Just below that </tbody> section you will find a form like <form method="post" action="options.php">
    now in this form add a <td> like

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

    this .

    Next we need to store this order value . therefore find a function there function wp_cycle_images_validate($input) {
    add this code below the last line of the function.

    if($value['order'])
    $input[$key]['order'] = wp_filter_nohtml_kses($value['order']);

    Now finally we need to modify the wp_cycle() function to our needs. So add some codes just below this(echo '<div id="'.$wp_cycle_settings['div'].'">'.$newline; ) line in wp_cycle($args = array(), $content = null) function.

    $sortArray = array();
    	foreach($wp_cycle_images as $imgs){
        foreach($imgs as $key=>$value){
            if(!isset($sortArray[$key])){
                $sortArray[$key] = array();
            }
            $sortArray[$key][] = $value;
        }
    	}
    $orderby = "order";
    array_multisort($sortArray[$orderby],SORT_ASC,$wp_cycle_images);

    thats it. It worked for me. Let me know if it helps. and sorry for my bad English.

  5. cubecolour
    ɹoʇɐɹǝpoɯ
    Posted 1 year ago #

    Thanks Gyan, looks like a good solution.

  6. Gyan Gaurav
    Member
    Posted 1 year ago #

    Really ?? Welcome . :)

    it would be great if it helps someone.

  7. RustyBadRobot
    Member
    Posted 1 year ago #

    Great Stuff Gyan! This makes a good plugin a much better one!

  8. vitamineg
    Member
    Posted 1 year ago #

    Thanks Gyan. ;)

  9. Gyan Gaurav
    Member
    Posted 1 year ago #

    Thanks Rusty ! :)
    your'e welcome vitamineg. have you tried the solution ?

  10. vitamineg
    Member
    Posted 1 year ago #

    Yes, I just implemented the code Gyan. Brilliant. Thank you kind Sir.

    :D

  11. Gyan Gaurav
    Member
    Posted 1 year ago #

    Nice.. Please mark it resolved

  12. vitamineg
    Member
    Posted 1 year ago #

    ::resolved::

  13. cdibi
    Member
    Posted 1 year ago #

    Any way that the plug in can be updated to include this code?

  14. Gyan Gaurav
    Member
    Posted 1 year ago #

    That's the best way I could have helped mate. You need any further assistance you can contact me for custom work here.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WP-Cycle
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags

No tags yet.