trentm / trentm/python-markdown2

[shadow] "img sizes" patch from James Eagan

Open
#10 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
2.8k
Forks
459
Avg merge
2d 19h
Merged PRs (30d)
4

Description

_This is a _shadow issue* for Issue 10 on Google Code (from which this project was moved).
Added 2007-11-28T04:51:21.000Z by tre...@gmail.com.
Labels: Type-Enhancement, Priority-Low.
Please make updates to the bug there.*

Original description

James wrote:

[A patch] to automatically calculate image sizes and insert
them into the generated HTML (see the attached patch, made off the svn
trunk).  Whenever it's about to write an HTML <img> tag, it checks if
the url is relative or absolute.  If it's absolute, it loads the URL
and tries to calculate the dimensions of the image.  If it's relative,
it checks to see if a file exists on the local filesystem relative to
the current working directory and uses that for the size.  Whenever it
can't find the size, it omits the width and height attributes, falling
back to the existing behavior.

This patch uses two approaches for calculating image sizes.  First, it
tries to use Cocoa's NSImage on the Mac.  Of course, this will fail on
non-Macs, so it then falls back to trying to use the Python Imaging
Library (PIL).  (I don't use PIL first, since it is sometimes compiled
without PNG or JPEG support.)  Finally, if none of those libraries is
available, it just reverts to the current behavior, omitting the size
attributes.

Please feel free to use this patch as you see fit.  I have not written
any test cases for it, nor have I given it any sort of a rigorous
quality assurance.  It works for me on my machine with my input files,
but I haven't tried it under any other setup.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

This is a shadow issue and directs updates to Google Code Issue 10, where an attached patch is referenced. Start there and review the proposed image-size behavior: determine dimensions for supported absolute or relative image URLs when possible, while preserving omitted width and height attributes when no size can be found.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
web-dev
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.