Forum Replies Created

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • in reply to: retina.js use in child theme template path #253234

    thanks to the code ninjas @ kriesi.at = excellent support guys!
    THANKS!

    But it does not seem to work on post thumbs – i don’t know why …?

    For all searching people: use this script in functions.php – with your extension:

    // Enqueueing retina.js
    if(!is_admin())
    {
    	add_action('wp_enqueue_scripts', 'avia_register_child_frontend_scripts', 100);
    }
    
    function avia_register_child_frontend_scripts()
    {
    	$child_theme_url = get_stylesheet_directory_uri();
            wp_enqueue_script( 'retina_js', $child_theme_url.'/js/retina.js', '', '', true );
    }
    
    add_filter( 'wp_generate_attachment_metadata', 'retina_support_attachment_meta', 10, 2 );
    /**
     * Retina images
     *
     * This function is attached to the 'wp_generate_attachment_metadata' filter hook.
     */
    function retina_support_attachment_meta( $metadata, $attachment_id ) {
        foreach ( $metadata as $key => $value ) {
            if ( is_array( $value ) ) {
                foreach ( $value as $image => $attr ) {
                    if ( is_array( $attr ) )
                        retina_support_create_images( get_attached_file( $attachment_id ), $attr['width'], $attr['height'], true );
                }
            }
        }
    
        return $metadata;
    }
    
    /**
     * Create retina-ready images
     *
     * Referenced via retina_support_attachment_meta().
     */
    function retina_support_create_images( $file, $width, $height, $crop = false ) {
        if ( $width || $height ) {
            $resized_file = wp_get_image_editor( $file );
            if ( ! is_wp_error( $resized_file ) ) {
                $filename = $resized_file->generate_filename( $width . 'x' . $height . '@2x' );
    
                $resized_file->resize( $width * 2, $height * 2, $crop );
                $resized_file->save( $filename );
    
                $info = $resized_file->get_size();
    
                return array(
                    'file' => wp_basename( $filename ),
                    'width' => $info['width'],
                    'height' => $info['height'],
                );
            }
        }
        return false;
    }
    
    add_filter( 'delete_attachment', 'delete_retina_support_images' );
    /**
     * Retina Bilder loeschen
     *
     */
    function delete_retina_support_images( $attachment_id ) {
        $meta = wp_get_attachment_metadata( $attachment_id );
        $upload_dir = wp_upload_dir();
        $path = pathinfo( $meta['file'] );
        foreach ( $meta as $key => $value ) {
            if ( 'sizes' === $key ) {
                foreach ( $value as $sizes => $size ) {
                    $original_filename = $upload_dir['basedir'] . '/' . $path['dirname'] . '/' . $size['file'];
                    $retina_filename = substr_replace( $original_filename, '@2x.', strrpos( $original_filename, '.' ), strlen( '.' ) );
                    if ( file_exists( $retina_filename ) )
                        unlink( $retina_filename );
                }
            }
        }
    }
    // FUNCTIONS END RETINA SCRIPT
    
    • This reply was modified 10 years, 8 months ago by basmati.
    in reply to: Change Logo for Logged in users #252226

    hey, thanks to all of you – function works well!

    in reply to: Change Background Color for one page #251836

    ok, got it with a lot of css styles and page ids. topic closed

    in reply to: Change Logo for Logged in users #251826

    and i have another addition: i need one specific page where i need the same styling like on the logged-in user pages.
    is ot possible to extend the function with a page id – that shows the logged-in logo?

    * the logo header implementation is a little comlicated in enfold – i had several themes, where its build as background into the page titel. don’t you think that would be more flexible for customization … ?

    in reply to: Change Logo for Logged in users #251345

    yep ismael, that works – but after surfing some pages the logo link points to the same page your on.
    my knowledge of php is not so strong – but it seems like it needs a piece of code for outputing the home link on every page / post.
    do you know what i mean?

    also – the search form is missing in the main menu for logged in users

    • This reply was modified 10 years, 8 months ago by basmati.
    in reply to: Retina Ready #249199

    thanks josue, works perfect!

    in reply to: Retina Ready #248933

    ok – i found it
    but there seems to be no media query for the logo –
    the height is reduced to 80px (!important) – why is that?

    how to change the height?
    the file is 600px x 70px @2x = 300px x 35px (2:1)

    .responsive .logo a, .responsive .logo img {
        height: 80px !important;
        margin: 0 auto;
        max-height: 80px !important;
        max-width: 100%;
    }
    • This reply was modified 10 years, 8 months ago by basmati.
    in reply to: Retina Ready #248890

    thanks Yigit, but now the mobile responsive view looks awfull. enfold enlarges the logo for mobile devices. now i’m seacrching for the enfold media queries – can you give me a hint where to find them in the parent theme?

    in reply to: Retina Ready #248878

    it worked out with that function:
    http://code.tutsplus.com/tutorials/ensuring-your-theme-has-retina-support–wp-33430

    • This reply was modified 10 years, 8 months ago by basmati.
Viewing 9 posts - 1 through 9 (of 9 total)