<commit_before>import { Directive, ElementRef, Input } from '@angular/core';
import {Photo} from "../data.types";

@Directive({ selector: '[tumblrImage]' })
export class TumblrImageDirective{
    @Input('tumblrImage') photo: Photo;
    private el: ElementRef;
    constructor(el: ElementRef) {
        this.el = el;
    }

    ngOnInit(){
        this.el.nativeElement.setAttribute("src", this.photo.alt_sizes[this.photo.alt_sizes.length - 1].url);
        this.el.nativeElement.setAttribute("srcset", this.createSrcSet());
    }

    private createSrcSet(): string {
        let srcset: string = "";
        this.photo.alt_sizes.forEach(picture => {
            srcset += picture.url + " " + picture.width + "w, "
        });
        srcset.substring(0, srcset.lastIndexOf(", "));
        return srcset;
    }
}<commit_msg>set image height in tumblrImageDirective<commit_after>import { Directive, ElementRef, Input } from '@angular/core';
import {Photo} from "../data.types";

@Directive({ selector: '[tumblrImage]' })
export class TumblrImageDirective{
    @Input('tumblrImage') photo: Photo;
    private el: ElementRef;
    constructor(el: ElementRef) {
        this.el = el;
    }

    ngOnInit(){
        this.el.nativeElement.setAttribute("src", this.photo.alt_sizes[this.photo.alt_sizes.length - 1].url);
        this.el.nativeElement.setAttribute("srcset", this.createSrcSet());
        this.el.nativeElement.setAttribute("height", this.getHeight(this.el.nativeElement.width))
    }

    private getHeight(width: number): string {
        let ratio = this.photo.original_size.height / this.photo.original_size.width;
        return Math.round(width * ratio) + "px";
    }

    private createSrcSet(): string {
        let srcset: string = "";
        this.photo.alt_sizes.forEach(picture => {
            srcset += picture.url + " " + picture.width + "w, "
        });
        return srcset.substring(0, srcset.lastIndexOf(", "));
    }
}
{'fraction_non_alphanumeric': 0.1500513874614594, 'fraction_numerical': 0.0020554984583761563, 'mean_word_length': 3.05625, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5005845', 'n_tokens_mistral': 612, 'n_tokens_neox': 595, 'n_words': 111}