Support » Plugin: Enable Media Replace » Issue with time when media updated

  • I see some others complaining about the date/time changing when updating media. For one, I would be on the side of NOT updating it but I can see the desire to do so. I would definitely suggest an option to appease everyone.

    HOWEVER, I have another related issue. Since the date/time IS being updated, the TIME is being updated incorrectly. I just updated a file at 4:36 PM (16:36) eastern time. Media Replace set the time to 21:36, e.g. 9:36 PM.

Viewing 11 replies - 1 through 11 (of 11 total)
  • Thread Starter Matt

    (@syntax53)

    While I assumed this to be obvious, I figured I’d add a note that this is a time zone issue. I am GMT-5.

    Plugin Author ShortPixel

    (@shortpixel)

    Thank you Matt,
    we’re going to add a new option so that the replaced image can have the date changed or not.
    This will come with our next plugin update (not sure when this will happen).

    In the meantime you can downgrade EMR plugin to an older version where the date wasn’t updated.

    Best regards,
    Alex

    Thread Starter Matt

    (@syntax53)

    To be clear: my issue wasn’t with the time being updated, but HOW it’s being updated. I was pointing out a bug.

    Thread Starter Matt

    (@syntax53)

    Here is your fix: https://www.diffchecker.com/a6wGmPQV

    basically you want to use:

    $post_date = current_time('mysql');
    $post_date_gmt = get_gmt_from_date($current_time);

    and then use those values in your UPDATE command for post_date and post_date_gmt.

    $sql = $wpdb->prepare(
    	"UPDATE $table_name SET post_date = '$post_date', post_date_gmt = '$post_date_gmt' WHERE ID = %d;",
    	$ID
    );
    $wpdb->query($sql);

    I got the idea from here: https://wp-mix.com/update-wordpress-post-current-time/

    Tested and works.

    (and you have this in two places, one for replace and the other for replace_and_search)

    • This reply was modified 2 years, 4 months ago by Matt.
    Plugin Author ShortPixel

    (@shortpixel)

    @syntax53: thank you for clarifying this and for the code example, we’ll be sure to include it.

    Thank you for your support,
    Alex

    I would also like to see this fixed, as it would be nice to have the exact date (if far from GMT time)

    Thread Starter Matt

    (@syntax53)

    I obviously didn’t review my code well enough before posting that fix. I forgot to change a variable name from the source. It should be–

    $post_date = current_time('mysql');
    $post_date_gmt = get_gmt_from_date($post_date);

    … not the ‘$current_time’ that I had.

    Plugin Author ShortPixel

    (@shortpixel)

    Thank you Matt!

    Thread Starter Matt

    (@syntax53)

    You didn’t include this fix in your latest update 🙁

    https://www.diffchecker.com/OJsg267U

    • This reply was modified 2 years, 2 months ago by Matt.
    • This reply was modified 2 years, 2 months ago by Matt.
    Plugin Author ShortPixel

    (@shortpixel)

    @syntax53 you’re right, it was an unexpected update and didn’t get a chance to include it 🙁
    Thank you for your understanding!

    If you find a moment to make pull request here
    https://github.com/short-pixel-optimizer/enable-media-replace
    we’d be sure to include your fix in the next plugin update.

    Best regards,
    Alex

    Thread Starter Matt

    (@syntax53)

    you’ve missed this fix again. I’ve created a pull request:

    https://github.com/short-pixel-optimizer/enable-media-replace/pull/26

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Issue with time when media updated’ is closed to new replies.